This article describes how to connect python to an Oracle database. The example shows how to use the cx_Oracle module to operate an Oracle database in Python, for more information about how to connect python to an Oracle database, see the example in this article. Share it with you for your reference. The details are as follows:
To connect to the Oracle database using python, you must reference the cx_Oracle database.
# Coding = UTF-8 import cx_Oracle def hello (): ''' Hello cx_Oracle example: 1) print database version information. 2) query table data. '''conn = cx_Oracle.connect ("obs61", "obs61", "tx8i. hp ") cur = conn. cursor () try: print "Oracle Version: % s" % conn. version print "Table SUB_POLICY rows:" cur.exe cute ('select * from wlan_future_event ') for row in cur: print row finally: cur. close () conn. close () hello ()
I hope this article will help you with Python programming.