Connecting to remote Oracle db via Python

P

pstatham

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)

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)
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
 
A

Anurag Chourasia

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=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

Regards,
Anurag
 
A

Anurag Chourasia

Try this please and it should work.

Connection_String =
'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12)(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

I'm sorry i missed a bracket there.

Regards,
Anurag


Doesn't seem to work

-----Original Message-----
From: Anurag Chourasia [mailto:[email protected]]
Sent: 17 February 2011 14:41
To: Paul Statham
Cc: (e-mail address removed)
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=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

Regards,
Anurag
 
A

Anurag Chourasia

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

Try this please and it should work.

Connection_String =
'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12)(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

I'm sorry i missed a bracket there.

Regards,
Anurag


Doesn't seem to work

-----Original Message-----
From: Anurag Chourasia [mailto:[email protected]]
Sent: 17 February 2011 14:41
To: Paul Statham
Cc: (e-mail address removed)
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=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))'

db = cx_Oracle.connect(Connection_String)

Regards,
Anurag

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:eek:racle:thin:mad: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
 
A

Alexander Gattin

Hello,

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?

Try 'tnsping service' or 'sqlplus uid/pwd@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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top