我是python和oracle的新手,我编写了连接到oracle数据库11g的代码,但是它给出了一个错误:
import cx_Oracle
con=cx_Oracle.connect('sys/Satyam123@localhost/xe')
con.close(
)
It gives the following error in pycharm:"C:/Users/DELL/Desktop/PYTHON/module2/check.py",C:/User/DELL/Desktop/PYTHON/ module 2 /check.py回溯(最近一次调用):文件con=cx_Oracle.connect('sys/Satyam123@localhost/xe') cx_Oracle.DatabaseError: DPI-1047: 32位C:\Users\DELL\venv\module2\Scripts\python.exe客户端库无法加载:“找不到指定的模块”。有关帮助,请参见https://oracle.github.io/odpi/doc/installation.html#windows
发布于 2018-07-02 10:13:37
请下载并安装Oracle客户端。( Oracle客户端有几个版本,但即时版本就可以了):
http://download.oracle.com/otn/nt/instantclient/122010/instantclient-basic-nt-12.2.0.1.0.zip
一旦安装完毕,cx_Oracle python模块将查找Oracle (OCI)并加载它们。
发布于 2018-12-05 16:18:33
我也有过同样的问题。请遵循链接https://oracle.github.io/odpi/doc/installation.html并安装Oracle 64位或32位,按照您的系统版本。一旦安装完毕,python将能够自动找到Oracle客户端库,并且您可以成功地连接到数据库。
发布于 2020-08-06 20:05:22
似乎存在与PATH.You相关的问题,可以尝试使用IDE terminal.In安装软件包--您只需尝试安装一个带有pycharm终端的包。
之后,尝试执行以下脚本:
import cx_Oracle
import db_config
user="test"
pw="test"
dsn="localhost:port/TEST" #here TEST is service id
con = cx_Oracle.connect(user, pw, dsn)
cur = con.cursor()
cur.execute("select * from test_table")
res = cur.fetchall()
for row in res:
print(row)仍然有问题,那么你可以参考:
https://oracle.github.io/python-cx_Oracle/samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html
https://stackoverflow.com/questions/51126056
复制相似问题