cx_Oracle.DatabaseError: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

  • From: jose soares <jose.soares@xxxxxxxxxxxxxx>
  • To: ORACLE-L <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 13 Dec 2011 17:39:46 +0100

Hi all,

I'm trying to connect to a server oracle using cx_Oracle and I get the 
error:

cx_Oracle.DatabaseError: ORA-12505: TNS:listener does not currently know 
of SID given in connect descriptor

Here my code:

def init_db_conn(parms):
    global _CONN
    import cx_Oracle
    dsn = cx_Oracle.makedsn(parms['host'],parms['port'],parms['dbname'])
    dbinfo = 'db: %s@%s' % (parms['user'], parms['dbname'])
    try:
        if not _CONN:
            _CONN = cx_Oracle.connect(parms['user'], parms['password'], dsn)
    except:
        ex = sys.exc_info()
        s = 'Exception: %s: %s\n%s' % (ex[0], ex[1], dbinfo)
        print s
        return None
    return _CONN



if I use instead the following code it works:

conn = 'myusername/Sf3r4c4rt4@xxxxxxxxxxxx:1521/SHELL'
cc = cx.connect(conn)
print cc.version
cc.close()

What's wrong with the first function where I use makedsn?


thanks for any help.
j




--
http://www.freelists.org/webpage/oracle-l


Other related posts: