일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 알고리즘
- Python
- GitHub
- SciPy
- pandas
- LSTM
- dataframe
- install
- pycharm
- index
- imread
- Button
- mariadb
- pip
- DFS
- synology
- E-P1
- RNN
- mean
- Lotto
- GT-S80
- Numpy
- javascript
- SPL
- ipad
- 삼성소프트웨어멤버십
- keras
- Series
- CNN
- Splunk
- Today
- Total
잠토의 잠망경
[python] cx_Oracle 설정 및 간단 사용 본문
https://github.com/yiwonjae/Project_Book_012/blob/master/sample/sample001.py
사전 준비
① instant-client download
② cx-oracle download
[사전 준비] instant-client download
https://www.oracle.com/database/technologies/instant-client/downloads.html
Oracle Instant Client Downloads
No results found Your search did not match any results. We suggest you try the following to help find what you're looking for: Check the spelling of your keyword search. Use synonyms for the keyword you typed, for example, try “application” instead of “sof
www.oracle.com
instant Client for Microsoft Windows(x64) 클릭 하고 다음으로 넘어간다.
나는 11g를 사용하므로 11.2를 선택하고 다운로드한다.
그리고 적당한 위치에 압축을 푼다.
나는 C Drive에 풀었다.
[사전 준비] cx-oracle download
cx-oracle을 다운로드 한다.
[접속] 접속 정보
CATEGORY | 값 |
HOST | IP |
PORT | port |
SID | sid |
ID | id |
PW | pw |
[접속] NLS 맞추기
SELECT USERENV('LANGUAGE') FROM dual
해당 결과는 os.putenv로 활용된다.
[접속] TEST SAMPLE
일반 활용
import os
os.chdir('C:\\instantclient-basic-windows.x64-11.2.0.4.0\\instantclient_11_2')
os.putenv('NLS_LANG', 'AMERICAN_AMERICA.UTF8')
import cx_Oracle
db = cx_Oracle.connect('id','pw', 'ip:port/sid')
print('{}'.format(db.version))
sql = 'select * from dual'
cursor = db.cursor()
cursor.execute(sql)
for row in cursor:
print(row)
cursor.close()
db.close()
pandas 활용
import os
os.chdir('C:\\instantclient-basic-windows.x64-11.2.0.4.0\\instantclient_11_2')
os.putenv('NLS_LANG', 'AMERICAN_AMERICA.UTF8')
import cx_Oracle
db = cx_Oracle.connect('id','pw', 'ip:port/sid')
print('{}'.format(db.version))
import pandas as pd
datas = pd.read_sql(sql='select * from dual', con = db)
db.close
참고
ojdbc6.jar 받는 위치
https://www.oracle.com/database/technologies/jdbc-drivers-12c-downloads.html
Oracle Database 12c Release 1 JDBC Driver Downloads
(875,817 bytes) - (SHA1 Checksum: 72cb63ec369807bd3a889c19ad715bf14b9adeb2) The download contains README-JDBC, README-UCP, jdbc-demo.tar, ucpdemos.jar, Javadoc-JDBC.zip, ucp_javadoc.zip, and README.txt that has more information about the contents of the ta
www.oracle.com
NLS 확인하기
SELECT * FROM NLS_DATABASE_PARAMETERS