Connecting to remote Oracle db via Python

Anurag Chourasia anurag.chourasia at gmail.com
Thu Feb 17 09:38:23 EST 2011


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

On Thu, Feb 17, 2011 at 4:10 PM, pstatham <pstatham at sefas.com> 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
>



More information about the Python-list mailing list