如果按照之前的文章已经下载并配置完oracle client,其实在Jupyter notebook 已经可以进行连接远程oracle的数据库了。对了!需要确保已经安装了cx_Oracle包,如果没有安装,打开terminal,输入pip install cx_Oracle即可。之后打开一个jupyter notebook,在cell 中输入:
import cx_Oracle
con = cx_Oracle.connect('username', 'password', 'dsn')
如果没有报错,表明连接成功。
但是如果只是按照之前的文章,下载并配置oracle client,在pycharm中想用python连接远程oracle数据库,运行和jupyter notebook同样的code
import cx_Oracle
con = cx_Oracle.connect('username', 'password', 'dsn')
这时候会出现这个错误"DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "
我看到网上的解决方法,可以点击这里查看原文,我也将其复制粘贴到下边:
“ 原因是我的python2.7是64位的,并且装了cx_oracle6.1库,而数据库用了32位的instantclient-basic。
解决方案:下载个64位的,然后解压,配置64位的instantclient-basic路径到系统环境变量Path,