问题使用连接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()
答案 0 :(得分:0)
这里是cx_Oracle Windows installation instructions,您可能会在引用的错误消息中找到它。
我将假设(i)您实际上具有64位Oracle客户端库11g或更高版本,并且(ii)具有安装说明中提到的所需VS Redistributable。然后尝试尝试的简单方法是将其添加到脚本顶部:
cx_Oracle.init_oracle_client(lib_dir=r"C:\oracle\instantclient_19_6")
使用客户端库的实际路径。
PHP可能是32位并使用32位Oracle库。如果是这样,因为您具有64位Python,则需要安装64位Instant Client或32位Python。