【发布时间】:2020-02-20 06:24:19
【问题描述】:
尝试使用 Python cx_Oracle 连接到 Oracle 数据库。在 sqlplus 中,当我连接到本地数据库时,我确实使用了“sqlplus / as sysdba”。 我试图在 Python 中使用没有密码的相同方法,但得到 ORA-01017 或 ORA-12541
tns_entry=cx_Oracle.makedsn('localhost',1521,'db1')
>>> conn = cx_Oracle.connect(mode = cx_Oracle.SYSDBA,dsn=tns_entry)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12541: TNS:no listener
>>> conn = cx_Oracle.connect("/",mode = cx_Oracle.SYSDBA,dsn=tns_entry)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12541: TNS:no listener
>>> conn = cx_Oracle.connect(mode = cx_Oracle.SYSDBA,dsn="TNS SERVICE")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-01017: invalid username/password; logon denied
我哪里错了?请提供您的意见。谢谢
【问题讨论】:
-
这个答案能解决你的问题吗stackoverflow.com/questions/13358656/…?
-
抱歉,没有。我的问题,我猜更多关于 Python 和 cx_Oracle 而不是数据库。通过 sqlplus 我可以使用监听器进行连接。
-
好吧,你得到了数据库错误。这意味着您可以到达指定为 ORA-##### 的 DB 和 gettin Oracle 错误。我建议您在 Oracle 社区和 Stackoverflow 上查看这些错误代码。