cx_Oracle-6.4.1在centos7.4上的安装

1、操作系统:

root@scm02[/scm/soft]#cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

cx_Oracle版本:

root@scm02[/scm/soft]#ll
total 248
drwxrwxr-x. 9 1000  1000    212 Sep 10 15:50 cx_Oracle-6.4.1

cx_Oracle6.4版本目前已验证了支持

Oracle Client 11.2, 12.1 and 12.2 and Python 2.7, 3.4, 3.5 and 3.6.

centos7.4自带的是python2.7,所以支持。

root@scm02[/scm/soft/cx_Oracle-6.4.1]#python -V
Python 2.7.5

2、安装

直接解压源码包文件:

tar -xzvf cx_Oracle-6.4.1.tar.gz

然后进入到解压目录中去

root@scm02[/scm/soft]#ls
cx_Oracle-6.4.1  cx_Oracle-6.4.1.tar.gz  jdk1.8.0_144
root@scm02[/scm/soft]#cd cx_Oracle-6.4.1
root@scm02[/scm/soft/cx_Oracle-6.4.1]#ls
build  cx_Oracle.egg-info  dist  LICENSE.txt  MANIFEST.in  odpi  PKG-INFO  README.txt  samples  setup.cfg  setup.py  src  test
root@scm02[/scm/soft/cx_Oracle-6.4.1]#

执行安装命令:

python setup.py build install

等待安装完成即可。

3、测试

oracle@scm02[/home/oracle]$view connet_oracle.sh
import cx_Oracle
conn = cx_Oracle.connect('数据库用户名/密码@数据库主机ip/数据库服务名')
curs=conn.cursor()
sql='SELECT * FROM dual'
rr=curs.execute (sql)
row=curs.fetchone()
print(row[0])
curs.close()
conn.close()

执行:

oracle@scm02[/home/oracle]$python connet_oracle.sh
X
oracle@scm02[/home/oracle]$

成功。

猜你喜欢

转载自blog.csdn.net/kadwf123/article/details/82591215