【发布时间】:2020-11-23 20:28:26
【问题描述】:
使用连接 oracle 到 python 源的问题,oracle 现在可以用于其他语言 php (oci)
错误:
Traceback (most recent call last):
File "c:\xampp\htdocs\pyoracle\testConnectionOracle.py", line 4, in <module>
conn = cx_Oracle.connect('xxx','xxx', dsn_tns,'UTF-8')
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "failed to get message for Windows Error 126". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
代码:
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('192.168.1.217', '1521', service_name='xx')
conn = cx_Oracle.connect('xx','xx', dsn_tns,'UTF-8')
c = conn.cursor()
c.execute('select * from database.table')
for row in c:
print (row[0], '-', row[1])
conn.close()
【问题讨论】:
-
是
ORACLE_HOME设置在您的PATH中吗? -
如果正在使用 Oracle Instant Client,那么您不会(也不应该)设置 ORACLE_HOME。
标签: python windows oracle cx-oracle