1. First install the cx_Oracle package
2. Unzip instantclient-basic-windows.x64-11.2.0.4.0.zip to c:\oracle
3. Copy all .dll files under instantclient_11_2 to c: \python34\Lib\site-packages\ (copy to the corresponding site-packages folder according to your own python version)
Python connection example code:
# -*- coding: utf-8 -*-import cx_Oracle conn=cx_Oracle.connect('reporter','password','localhost:1521/ORCL') cursor=conn.cursor() sql="select * from test"cursor.execute(sql) data=cursor.fetchall()print(data) cursor.close() conn.commit() conn.close()
The above is the detailed content of How to connect to oracle database instance using python under windows. For more information, please follow other related articles on the PHP Chinese website!