Mac 下python 连接 oracle

半腔热情 提交于 2020-02-04 20:49:47

 

  • 下载oracle client

https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

 

  • 解压
mkdir -p /opt/oracle
unzip instantclient-basic-macos.x64-19.3.0.0.0dbru.zip

mkdir ~/lib
ln -s /opt/oracle/instantclient_19_3/libclntsh.dylib ~/lib/

 

  • python 库

pip intall cx_Oracle

 

  • python 测试
#  '用户名/密码@IP:端口号/SERVICE_NAME'

import cx_Oracle
conn = cx_Oracle.connect("username/password@ip:port/servicename")
cursor = conn.cursor()

result=cursor.execute('Select * from table where rownum = 1')


# read to pandas
query = 'Select * from table where rownum = 1'
pd.read_sql(query, con=conn)

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!