您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python连接oracle

bubuko 2022/1/25 19:37:50 python 字数 745 阅读 785 来源 http://www.bubuko.com/infolist-5-1.html

python连接oracle时需要下载cx_Oracle库, 使用pycharm,下载时注意使用在File | Settings | Project: workspace | Project Interpreter中进行下载,直接使用pip下载时很可能会报错。 import cx_Oracle as ...

python连接oracle时需要下载cx_Oracle库,

使用pycharm,下载时注意使用在File | Settings | Project: workspace | Project Interpreter中进行下载,
直接使用pip下载时很可能会报错。

import cx_Oracle as cx
con = cx.connect(‘root‘, ‘root123‘, ‘127.0.0.1:1521/ORCL‘) #创建连接
cursor = con.cursor() #创建游标
cursor.execute("select * from dual") #执行sql语句
data = cursor.fetchone() #获取一条数据
print(data) #打印数据
cursor.close() #关闭游标
con.close() #关闭数据库连接

python连接oracle

原文:https://www.cnblogs.com/iqingchun/p/13214821.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶