下面的资料是关于python链接Oracle数据库的的内容,应该能对小伙伴有些用途。
#coding=UTF-8
import cx_Oracle
def hello():
‘’‘Hello cx_Oracle示例:
1)打印数据库版本信息.
2)查询表数据.’’’
conn = cx_Oracle.connect(“obs61”,“obs61”,“tx8i.hp”)
cur = conn.cursor()
try:
print “Oracle Version:%s” % conn.version
print “Table SUB_POLICY rows:”
for row in cur:
print row
finally:
cur.close()
conn.close()
hello()