이 글은 외부 서버에 오라클이 설치되어 있다고 가정합니다.
Oracle Instant Client 가 언제부터 ARM 맥용 버전이 생겼는지 모르겠는데 최근 작업할 일이 생기면서 다시 찾아보니 있어서 간단한 접속 방법을 설명합니다.

설치

Oracle Instant Client Downloads for macOS (ARM64)

https://www.oracle.com/database/technologies/instant-client/macos-arm64-downloads.html

Basic Package(DMG) 다운로드 → 마운트 → 경로 복사 → 터미널

 cd /Volumes/instantclient-basic-macos.arm64-23.3.0.23.09
 sh ./install_ic.sh
 // /Users/계정/Downloads/instantclient_23_3 에 복사됨
 // 확인 후 마운트 해제

Conda cx_Oracle 설치

conda activate env이름
conda install cx_Oracle

Python 코드

import cx_Oracle
cx_Oracle.init_oracle_client(lib_dir="/Users/맥계정/Downloads/instantclient_23_3")
dsn = cx_Oracle.makedsn(host='아이피', port='포트', service_name='서비스이름 or SID')
conn = cx_Oracle.connect(user='오라클계정', password='오라클비번', dsn=dsn)
curosr = conn.cursor()
cursor.execute("select * from 테이블명")
for row in cursor:
	print(row)
cursor.close()
conn.close()

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다