python 链接oracle

2023-06-14  本文已影响0人  后知不觉1

1、python 环境

需要python3 环境,参考https://www.jianshu.com/p/3d351bdd4196

2、依赖包安装

    pip install cx_Oracle 

3、下载内核包

    yum install libaio
    mkdir   /opt/oracle/
    cd  /opt/oracle/
    https://download.oracle.com/otn_software/linux/instantclient/2110000/instantclient-basic-linux.x64-21.10.0.0.0dbru.zip
    unzip  instantclient-basic-linux.x64-21.10.0.0.0dbru.zip
    echo /opt/oracle/instantclient_21_1 > /etc/ld.so.conf.d/oracle-instantclient.conf
    ldconfig

4、链接

import cx_Oracle
conn = cx_Oracle.connect ('username','passwd','host:port/owner')
print(连接数据库成功!)
上一篇 下一篇

猜你喜欢

热点阅读