我试图在一个Python脚本中连接到2个Oracle数据库,但是在连接到第二个数据库时遇到了一些麻烦。我收到的错误是:
“ DatabaseError:ORA-01017:无效的用户名/密码;登录被拒绝”
我的登录信息是正确的,所以我对为什么不允许我访问第二个数据库感到困惑。任何见识将不胜感激。
下面的示例代码:
dsnStr = cx_Oracle.makedsn("database1", "port_for_db1", "sid_for_db1")
conn = cx_Oracle.connect("myusername","password_db1",dsn=dsnStr)
dsnStr2 = cx_Oracle.makedsn("database2", "port_for_db2", "sid_for_db2")
conn2 = cx_Oracle.connect("myusername","password_db2",dsn=dsnStr)
谢谢!
答案 0 :(得分:2)
您犯了一个错误dsn=dsnStr
dsnStr2 = cx_Oracle.makedsn("database2", "port_for_db2", "sid_for_db2")
conn2 = cx_Oracle.connect("myusername","password_db2",dsn=dsnStr2)