FAQ
Hi Guys,

I've installed the cx_Oracle module for Python and I'm trying to
connect to my remote Oracle db. Like so (username, password and ip
below aren't real don't worry)
uid = "scott"
pwd = "tiger"
service = "10.5.1.12:1521:PR10"
db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
This however gives me the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
or object
does not exist

I've also tried the following (jdbc string which works fine for java)
service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
identifier
specified

I'm not sure what's going on because I know that the ip, port and
service name. are correct? And as I said I can connect to it via JDBC
in Java.

Any ideas?

Thanks,
Paul

Search Discussions

  • Anurag Chourasia at Feb 17, 2011 at 2:38 pm
    Could you try by using a connecting string in the standard format as below?

    Connection_String 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST.5.1.12(PORT21)))(CONNECT_DATA=(SID=PR10)))'

    db = cx_Oracle.connect(Connection_String)

    Regards,
    Anurag
    On Thu, Feb 17, 2011 at 4:10 PM, pstatham wrote:
    Hi Guys,

    I've installed the cx_Oracle module for Python and I'm trying to
    connect to my remote Oracle db. Like so (username, password and ip
    below aren't real don't worry)
    uid = "scott"
    pwd = "tiger"
    service = "10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    This however gives me the following error:

    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
    or object
    ?does not exist

    I've also tried the following (jdbc string which works fine for java)
    service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
    identifier
    ?specified

    I'm not sure what's going on because I know that the ip, port and
    service name. are correct? And as I said I can connect to it via JDBC
    in Java.

    Any ideas?

    Thanks,
    Paul
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Anurag Chourasia at Feb 17, 2011 at 2:58 pm
    Try this please and it should work.

    Connection_String 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST.5.1.12)(PORT21)))(CONNECT_DATA=(SID=PR10)))'

    db = cx_Oracle.connect(Connection_String)

    I'm sorry i missed a bracket there.

    Regards,
    Anurag

    On Thu, Feb 17, 2011 at 8:18 PM, Paul Statham wrote:
    Doesn't seem to work

    -----Original Message-----
    From: Anurag Chourasia [mailto:anurag.chourasia at gmail.com]
    Sent: 17 February 2011 14:41
    To: Paul Statham
    Cc: python-list at python.org
    Subject: Re: Connecting to remote Oracle db via Python

    Could you try by using a connecting string in the standard format as below?

    Connection_String > 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST.5.1.12(PORT21)))(CONNECT_DATA=(SID=PR10)))'

    db = cx_Oracle.connect(Connection_String)

    Regards,
    Anurag
    On Thu, Feb 17, 2011 at 4:10 PM, pstatham wrote:
    Hi Guys,

    I've installed the cx_Oracle module for Python and I'm trying to
    connect to my remote Oracle db. Like so (username, password and ip
    below aren't real don't worry)
    uid = "scott"
    pwd = "tiger"
    service = "10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    This however gives me the following error:

    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
    or object
    ?does not exist

    I've also tried the following (jdbc string which works fine for java)
    service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
    identifier
    ?specified

    I'm not sure what's going on because I know that the ip, port and
    service name. are correct? And as I said I can connect to it via JDBC
    in Java.

    Any ideas?

    Thanks,
    Paul
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Anurag Chourasia at Feb 17, 2011 at 3:09 pm
    Apart from that, you could also use a shorter format which is a
    correction over what you were trying with earlier.

    Here......

    uid = "scott"
    pwd = "tiger"
    service = "//10.5.1.12:1521/PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)

    Please let us know how it goes.

    Regards,
    Anurag

    On Thu, Feb 17, 2011 at 8:28 PM, Anurag Chourasia
    wrote:
    Try this please and it should work.

    Connection_String > 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST.5.1.12)(PORT21)))(CONNECT_DATA=(SID=PR10)))'

    db = cx_Oracle.connect(Connection_String)

    I'm sorry i missed a bracket there.

    Regards,
    Anurag

    On Thu, Feb 17, 2011 at 8:18 PM, Paul Statham wrote:
    Doesn't seem to work

    -----Original Message-----
    From: Anurag Chourasia [mailto:anurag.chourasia at gmail.com]
    Sent: 17 February 2011 14:41
    To: Paul Statham
    Cc: python-list at python.org
    Subject: Re: Connecting to remote Oracle db via Python

    Could you try by using a connecting string in the standard format as below?

    Connection_String >> 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST.5.1.12(PORT21)))(CONNECT_DATA=(SID=PR10)))'

    db = cx_Oracle.connect(Connection_String)

    Regards,
    Anurag
    On Thu, Feb 17, 2011 at 4:10 PM, pstatham wrote:
    Hi Guys,

    I've installed the cx_Oracle module for Python and I'm trying to
    connect to my remote Oracle db. Like so (username, password and ip
    below aren't real don't worry)
    uid = "scott"
    pwd = "tiger"
    service = "10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    This however gives me the following error:

    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host
    or object
    ?does not exist

    I've also tried the following (jdbc string which works fine for java)
    service = "jdbc:oracle:thin:@10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    Traceback (most recent call last):
    ?File "<stdin>", line 1, in <module>
    cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect
    identifier
    ?specified

    I'm not sure what's going on because I know that the ip, port and
    service name. are correct? And as I said I can connect to it via JDBC
    in Java.

    Any ideas?

    Thanks,
    Paul
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Alexander Gattin at Feb 18, 2011 at 10:33 pm
    Hello,

    On Thu, Feb 17, 2011 at 02:40:22AM -0800, pstatham
    wrote:
    I've installed the cx_Oracle module for Python
    and I'm trying to connect to my remote Oracle
    db.
    Can you tnsping your remote Oracle DB
    successfully?
    uid = "scott"
    pwd = "tiger"
    service = "10.5.1.12:1521:PR10"
    db = cx_Oracle.connect(uid + "/" + pwd + "@" + service)
    Try 'tnsping service' or 'sqlplus uid/pwd at service'
    in your Korn/Bourne/whoever shell 1st. If this
    works, then cx_Oracle will work too.

    'service' must be specified in system TNSNAMES
    file or in your ~/.tnsnames.ora

    --
    With best regards,
    xrgtn

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 17, '11 at 10:40a
activeFeb 18, '11 at 10:33p
posts5
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase