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

From: jose soares <jose.soares_at_sferacarta.com>
Date: Tue, 13 Dec 2011 17:39:46 +0100
Message-ID: <4EE77FD2.5030207_at_sferacarta.com>



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_at_%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_at_myserver.net: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
Received on Tue Dec 13 2011 - 10:39:46 CST

Original text of this message