티스토리 뷰

Python

Python Oracle cx_oracle연동

j0n9m1n1 j0n9m1n1 2019.11.04 16:09
pip install cx_oracle

 

12.2버전 다운

https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html#ic_winx64_inst

 

Instant Client for Microsoft Windows (x64) 64-bit

No results found Your search did not match any results.

www.oracle.com

원하는 곳에 압축 해제 > 해당 폴더 위치 환경변수 추가(사용자변수 - PATH: ~~~~~~~;I:\instantclient_12_2)

 

import cx_Oracle

connection = cx_Oracle.connect("id", "password", "ip/sid(ex: xe, orcl)")
cursor = connection.cursor()
cursor.execute('query(ex: select * from table)')

for row in cursor:
    print(row)