本文實例講述了python鏈接Oracle數據庫的方法。分享給大家供大家參考。具體如下:
這裡使用python鏈接Oracle數據庫需要引用cx_Oracle庫
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #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:" cur.execute('select * from wlan_future_event') for row in cur: print row finally: cur.close() conn.close() hello()希望本文所述對大家的Python程序設計有所幫助。