简体   繁体   中英

Receiving ORA-01017 error (invalid username/password) when using cx_Oracle in Python

I'm trying to establish a connection to an oracle 12c database using python with the oracle_Cx library, but I've run into some difficulty. I am able to connect to the database successfully with two different usernames and passwords when I use PL/SQL developer (my normal user account and a second account that's using a dblink connection- though to be honest I don't know what that means, it's just what I've been told). When I try to connect to the database using python and the oracle_Cx library I'm able to connect without any difficulty using my normal user account, but when I try to use the dblink connection I am given the ORA-01017 error. I am 100% certain that I'm entering the password identically in both cases because I type the username and password into a text editor and then copy and paste it into PL/SQL and into the variable's I'm passing to the oracle_Cx.connect function, eg

oracle_ip = ourIpAddres
oracle_port = ourPort
oracle_SID = ourSID
oracle_username = standardUsername
oracle_password = standardPassword
oracle_selfserve_username = selfServeUsernane
oracle_selfserve_password = selfServePassword

I've read on some other stackoverflow posts that invalid username/password errors can arise because of a difference between the server and client's case sensitivity, and that this can be overcome by quoting the password, which I've also tried using

oracle_selfserve_password = '\"imagineThisIsMyPassword\"'

But that didn't help either.

Does anyone have any suggestions for me?

Thanks Brad

I've come up with a solution that works for the purpose of establishing a connection. Instead of passing cx_Oracle.connect the individual variable names, it works if you construct the actual connect string, eg

db_selfserve2 = cx_Oracle.connect('notMyRealUserName/notMyPassword@123.456.121.222:123456/serviceName')

You can find the service name by logging into the database using a client where you are able to connect successfully and issuing the following command

select sys_context('userenv','service_name') from dual;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM