链接oracle 需要安装相关的cx_Oracle 安装就不多说了
cx_Oracle 相关文档http://cx-oracle.readthedocs.io/en/latest/cursor.html
import cx_Oracle as cx
# 用户名,密码,tns
user = 'test'
password = 'test'
host = '192.168.186.120'
port = '1521'
sid = 'orcl'
dsn = cx.makedsn(host, port, sid)
con = cx.connect(user, password, dsn)
# 打开游标
curs = con.cursor()
row = curs.execute('select * from N_E_USER')
curs.
values = curs.fetchall()
print(values)
# 关闭连接
curs.close()
con.close()
结果如下
[('zhangsan','28','男'),('lisi','26','女')]