cx_Oracle DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library XXX
cx_Oracle报错:cx_Oracle DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library
·
报错信息:DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "D:\app\product\11.2.0\client_1\oci.dll is not the correct architecture
1.在网上找了很多,有说:
(1)增加oracle安装路径到环境变量的
(2)安装oracle程序(如没有安装,那你就去安装oracle程序)
(3)在最开始指定具体路径:cx_Oracle.init_oracle_client(lib_dir=r"D:\app\product\11.2.0")
但是都不行
2.看了官网-installation才知道原来有新的替代的库:oracledb(如下图)
3.安装使用教程-可进官网-开发者文档查看或看下面步骤
(1)安装3 位的 Python 7.64或更高版本
(2)安装python-oracledb
python -m pip install oracledb -i https://mirrors.aliyun.com/pypi/simple/
(3)python中调用
import oracledb
# 一般情况会在此处添加oracle的安装路径,避免报错
oracledb.init_oracle_client(lib_dir=r"your oracle path")
connection = oracledb.connect(
user = "用户名",
password = "密码",
dsn = "连接字")
cursor = connection.cursor()
cursor.execute("select * from yourdatabase")
for i in cursor:
print(i)
cursor.close()
connection.close()
更多推荐
已为社区贡献1条内容
所有评论(0)