
`sqlite3.extension_dir` 함수는 SQLite3 확장 모듈 디렉토리 위치를 반환하는 함수입니다. 이 함수를 사용하여 디렉토리 위치를 얻을 수 있습니다.
#hostingforum.kr
python
import sqlite3
# SQLite3 연결 객체 생성
conn = sqlite3.connect(':memory:')
cursor = conn.cursor()
# 확장 모듈 디렉토리 위치 확인
ext_dir = sqlite3.extension_dir()
print(ext_dir)
디렉토리 위치를 얻은 후, 확장 모듈을 로드하거나, 새로운 확장 모듈을 등록할 수 있습니다.
#hostingforum.kr
python
# 확장 모듈 로드
cursor.execute('SELECT load_extension("path/to/extension.so")')
result = cursor.fetchone()
print(result)
# 새로운 확장 모듈 등록
cursor.execute('SELECT register_extension("path/to/new_extension.so")')
result = cursor.fetchone()
print(result)
주의할 점은, `sqlite3.extension_dir` 함수는 SQLite3 연결 객체가 생성된 후에 호출해야 합니다. 또한, 확장 모듈의 경로를 정확하게 지정해야 합니다.
2025-07-05 05:32