September 25th, 2013, 03:24 PM
Using cx_Oracle with mode= cx_Oracle.SYSDBA and DSN
I'm completely new to Python. I'm finding difficulty figuring out how to connect as sysdba, which uses a Bequeath protocol. I always receive ORA-12514: TNS:listener does not currently know of service requested in connect descriptor. It appears that it does not like how I'm passing the dsn along with the mode when I call the Oracle python module. I can connect using connection = cx_Oracle.connect('system','manager',dsn) without a problem, which tells me that the dsn's correct. I have also printed out the dsn and have been able to make use of it to connect from the command line. I haven't been able to figure out how to pass the dsn along with using mode = cx_Oracle.SYSDBA.
host = 'localhost'
port = 1521
sid = 'devmon'
dsn = cx_Oracle.makedsn(host, port, sid)
connection = cx_Oracle.connect(dsn,mode = cx_Oracle.SYSDBA)
Any help would be appreciated.
Last edited by Alex55555; September 25th, 2013 at 03:25 PM.
Reason: for it to make more sense
September 25th, 2013, 04:57 PM
I found that the Connection method of module cx_Oracle, connection = cx_Oracle.Connection(dsn, mode = cx_Oracle.SYSDBA), requires a password but the dsn works.
cx_Oracle.DatabaseError: ORA-01005: null password given; logon denied
It will work if I include the password.
However, if I leave out the dsn and export the environment for Oracle 11g via from the shell, I can connect without a problem.
connection = cx_Oracle.Connection( mode = cx_Oracle.SYSDBA)
My question is how I can make local sysdba connections, as I would from the Linux command line without a password and make use of dsn? It seems to work one way or the other, but not the way I want it to.