Home >Backend Development >Python Tutorial >How to connect to oracle database instance using python under windows

How to connect to oracle database instance using python under windows

PHP中文网
PHP中文网Original
2017-06-20 15:06:162034browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn