您的位置:首页 > 数据库 > Oracle

pyhton链接oracle

2016-07-14 10:26 429 查看
链接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','女')]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: