1、首先需要安装好oracle数据库,本机适用plsql连接数据库正常,记录下数据库名称
2、安装cx_oracle模块
pip install cx_Oracle
3、python中引入模块
import cx_Oracle as cx
4、测试
conn = cx.connect(‘sys/[email protected]/orcl‘)
cursor = conn.cursor ()
cursor.execute ("select * from dual")
row = cursor.fetchone ()
print (row)
cursor.close ()
conn.close ()
时间: 2024-10-05 15:56:37