暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

离线安装cx_Oracle及驱动

Ty3306 2023-02-26
1868

python调用oracle数据依赖于cx_Oracle+oracle-instantclient

离线安装oracle客户端
安装oracle 11g
下载地址:https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
根据oracle的版本下载对应的rpm包:
清单:
oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
1
修改环境变量(三种方式)
#对所有用户生效(永久)
vim /etc/profile
source /etc/profile
#对单一用户生效(永久) 用户目录下文件/home/xxx/
vim ~/.bash_profile;
source ~/.bash_profile;
#执行允许export(对当前shell临时有效)
export ..........
#----------------------------------------------------------
vim ~/.bash_profile;
-----------------------------------------------------------
>export ORACLE_HOME=/usr/lib/oracle/11.2/client64
>export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
-----------------------------------------------------------
source ~/.bash_profile;
echo $ORACLE_HOME;#检查生效

#新建软连接
cd /usr/lib/oracle/11.2/client64/lib && ln –s libclntsh.so.11.1 libclntsh.so

 
安装cx_Oracle
下载地址:https://pypi.org/project/cx-Oracle/

安装cx_Oracle扩展包
pip install cx_Oracle-7.0.0-cp27-cp27mu-manylinux1_x86_64.whl;
python;
>import cx_Oracle
>cx_Oracle.SessionPool(user= 't', password= 't', dsn= '192.168.0.xxx:1521/orcl', min=1, max=10, increment=1)
>> :OK! 

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论