从 下载链接 下载下面两个文件
instantclient-basiclite-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip
解压这两个文件到/opt/instantclient_11_2目录下
export ORACLE_HOME=/opt/instantclient_11_2/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
安装cx_Oracle之前需要先建立一个链接libclntsh.so,如下:
cd /opt/instantclient_11_2/
ln -s libclntsh.so.11.1 libclntsh.so
执行安装
pip install cx_Oracle
import cx_Oracle
conn = cx_Oracle.connect('jhinno/[email protected]/jhinno')
cursor = conn.cursor ()
cursor.execute ("select sysdate from dual")
row = cursor.fetchone ()
print row
cursor.close ()
conn.close ()
转载请以链接形式标明本文地址
本文地址:http://blog.csdn.net/kongxx/article/details/50616943