본문 바로가기
서버/python

cx_Oracle 설치하기

by 아카이sun 2023. 8. 17.

파이썬에서 cx_Oracle을 사용하여 오라클에 접속해보자.

sudo의 권한을 가지고 있다고 가정하고 진행해보자.

우선 오라클 클라이언트에 접속하기 위해서는 네이티브 모듈이 필요하다.

상세한 방법은 다음을 참고하여도 좋다. 

https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html

 

진행 방법으로는 다음과 같다.

1. 설치할 폴더 생성

mkdir /opt/oracle

 

2. 모듈 다운로드

wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip

 

3. 압축 풀기

unzip instantclient-basic-linux.x64-21.6.0.0.0dbru.zip

 

4. 관련된 필수 라이브러리도 설치한다.

apt install libaio1 -y #우분투
yum install libaio -y #centos

 

5. ldconfig에 등록한다.

sh -c "echo /opt/oracle/instantclient_21_6 > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig

 

6. pip를 이용하여 cx_Oracle 파이썬 라이브러리를 설치해준다.

pip install cx_Oracle

 

 

'서버 > python' 카테고리의 다른 글

python 2.7에서 상위버전으로 업그레이드  (0) 2017.08.30

댓글