繁体   English   中英

与 Oracle DB 的 Python 连接:cx_Oracle

[英]Python Connection to Oracle DB: cx_Oracle

我目前正在尝试使用 cx_Oracle 连接到远程 Oracle 数据库。

#!/usr/bin/python3
import cx_Oracle

#create connection
connection = cx_Oracle.connect("User", "Password", "DBHost", 
encoding="UTF-8")
print('It Works!')

当我尝试连接到数据库时,我收到以下消息:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library

我在此消息后尝试了什么:

  1. 下载和安装 Oracle 客户端
    • 还是一样的消息
  2. 然后我添加了已安装客户端的路径变量
    • 还是一样的消息

我做错什么了吗 ?

猜测您使用的是 Linux。

在 Linux 上使用 Oracle Instant Client 的 cx_Oracle 安装说明在这里

尝试按照说明运行 ldconfig 或设置 LD_LIBRARY_PATH。

sudo sh -c "echo home/dtv/Installfiles/InstantClientOracle/instantclient_19_9 > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM