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

  • From: Niall Litchfield <niall.litchfield@xxxxxxxxx>
  • To: jose.soares@xxxxxxxxxxxxxx
  • Date: Wed, 14 Dec 2011 07:40:07 +0000

I can't say that I'm familiar with cx_connect, I can however say that the
listener.log will contain a record showing you what SID got passed to it as
a result of your call. I'd also try and ensure that the exception handling
prints out the values of the parms structure (array?)
On Tue, Dec 13, 2011 at 4:39 PM, jose soares <jose.soares@xxxxxxxxxxxxxx>wrote:

> 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
>
>
>
>
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


-- 
Niall Litchfield
Oracle DBA
http://www.orawin.info


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


Other related posts: