[英]Executing the sql queries on oracle DB using cx_Oracle in python throws error
Error: 错误:
DPI-1047: 32-bit Oracle Client library cannot be loaded: "The specified module could not be found"
Python: 蟒蛇:
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
I have installed 64 bit python but when I type python in my command prompt, it shows python application is of 32 bit. 我已经安装了64位python,但是当我在命令提示符下键入python时,它显示python应用程序是32位的。
Question: 题:
I am trying to run the SQL queries on a oracle Database residing on a remote server. 我试图在驻留在远程服务器上的oracle数据库上运行SQL查询。 I have used the below two methods to connect to the database and received the error mentioned above.
我使用以下两种方法连接到数据库,并收到上述错误。
## Method 1
ip='10.8.183.137'
port=1522
SID='DB10'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
log.info('dsn_tns: ' + dsn_tns)
db = cx_Oracle.connect('sys', 'OraPasswd01', dsn_tns)
##Method 2
dbconn = cx_Oracle.connect(connstr, mode=cx_Oracle.SYSDBA);
Method#2 works if I copy the script on the virtual server and run it, I want to implement this from my PC. 如果我要在虚拟服务器上复制脚本并运行它,而我想从PC上实现该方法,则方法2可以工作。
This error come when your Oracle Client is not installed or LD_LIBRARY_PATH is not set where libclntsh.so is present. 当未安装Oracle Client或在存在libclntsh.so的地方未设置LD_LIBRARY_PATH时,将发生此错误。
if you have Oracle client installed then search for libclntsh.so and set the LD_LIBRARY_PATH as 如果您已安装Oracle客户端,则搜索libclntsh.so并将LD_LIBRARY_PATH设置为
"export LD_LIBRARY_PATH=/app/bds/parcels/ORACLE_INSTANT_CLIENT/instantclient_11_2:$LD_LIBRARY_PATH" “导出LD_LIBRARY_PATH = / app / bds / parcels / ORACLE_INSTANT_CLIENT / instantclient_11_2:$ LD_LIBRARY_PATH”
Check following link for more details for Oracle client installation: oracle.github.io/odpi/doc/installation.html#linux 检查以下链接以获取有关Oracle客户端安装的更多详细信息:oracle.github.io/odpi/doc/installation.html#linux
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.