
geoip_db_filename 파라미터는 GeoIP 데이터베이스 파일의 경로를 지정하는 파라미터입니다.
파일 이름은 'GeoIP2-City.mmdb', 'GeoIP2-Country.mmdb', 'GeoLite2-City.mmdb', 'GeoLite2-Country.mmdb' 등이 가능합니다.
예를 들어, 'GeoIP2-City.mmdb' 파일을 사용하는 경우 geoip_db_filename 파라미터의 값을 다음과 같이 지정할 수 있습니다.
#hostingforum.kr
python
from geoip2.database import Reader
# GeoIP 데이터베이스 파일의 경로를 지정합니다.
reader = Reader('GeoIP2-City.mmdb')
또한, 파일 경로를 지정할 때는 절대 경로를 사용하는 것이 좋습니다. 상대 경로를 사용할 경우, 파일이 존재하지 않는 경우 오류가 발생할 수 있습니다.
#hostingforum.kr
python
# 상대 경로를 사용하는 경우
reader = Reader('./GeoIP2-City.mmdb')
# 절대 경로를 사용하는 경우
reader = Reader('/usr/local/share/GeoIP/GeoIP2-City.mmdb')
2025-05-31 22:49