windows下使用python操作oracle数据库

主要使用cx_Oracle:

http://cx-oracle.sourceforge.net/


安装oracle客户端


python脚本:

# -*- coding: utf-8 -*-
import cx_Oracle
                               
conn = cx_Oracle.connect('user/pass@IP/datebase') 
cursor = conn.cursor()
sqlcmd = '''
select * from test
'''
cursor.execute(sqlcmd)
rows = cursor.fetchall()
#row = cursor.fetchone()
for row in rows:
    print (row[0], row[1], row[2], row[3])
                               
cursor.close ()
conn.close ()