Python3.5在Windows 7下连接ORACLE数据库

 

1、首先需要安装好oracle数据库,本机适用plsql连接数据库正常,记录下数据库名称

image

2、安装cx_oracle模块

pip install cx_Oracle

3、python中引入模块

import cx_Oracle as cx

4、测试

conn = cx.connect('sys/pwd@localhost/orcl')    
cursor = conn.cursor ()  
cursor.execute ("select * from dual")  
row = cursor.fetchone ()  
print (row)    
cursor.close ()  
conn.close () 

posted @ 2018-02-27 00:07  江南一陈风  阅读(244)  评论(0编辑  收藏  举报