cx
•
数据库
报错信息: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](https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html)才知道原来有新的替代的库:oracledb(如下图)
- 3.安装使用教程-可进[官网-开发者文档](https://www.oracle.com/database/technologies/appdev/python/quickstartpythononprem.html)查看或看下面步骤
-
-
- (1)安装3 位的 Python 7.64或更高版本
- (2)安装python-oracledb
- (3)python中调用
-
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()
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/2ec00bf0a0.html
