Skip to main content

Easily get the country code from an ip address.

Project description

location_ipfire_db_reader

Introduction

I was looking for a geo-ip library where I can easily convert IPs into countries. And this preferably in Python and preferably offline.

Couldn't find any, but ipfires location utility came very close. Sadly it was coded in C.

That's why I re-interpreted the location databases structure into Python and made a tiny wrapper around it for easy access.

Installation:

pip install -U location-ipfire-db-reader

Main usage:

from location_ipfire_db_reader import LocationDatabase

# This call will _download the location database into the provided file.
#   It will not re-_download it if there are no updates.
db = LocationDatabase('location.db')
print(db.find_country('8.8.8.8'))  # US

This library should work for both IP4 & IP6.

Developers information

(or more accurately named: information for myself at a future point in time 😎)

  • decompress_db.py contains just the code to facilitate extraction of the database
  • download_db.py: download (or update) once a day the newest ipfire location database.
  • database.py: The wrapper (consumer-facing code) around the filehandling and reading and stuff.
  • interpret_location_db.py: contains the low-level interpretation of the database file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

location_ipfire_db_reader-1.0.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file location_ipfire_db_reader-1.0.4.tar.gz.

File metadata

File hashes

Hashes for location_ipfire_db_reader-1.0.4.tar.gz
Algorithm Hash digest
SHA256 6dbb4c21cafcc5e87c189f6ce45a7892d23f579bb66b7728efb9119b7cd567a0
MD5 092662e7f207b28425c9b2347fd39ebe
BLAKE2b-256 2ffc9923241ed2c242021b4ddf03334b012a8ec4f101716cd2a3060418fce0b1

See more details on using hashes here.

File details

Details for the file location_ipfire_db_reader-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for location_ipfire_db_reader-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 44a6c559b6b84380ea78018e365ed2fb7199612c7d25967ee2696714443718bb
MD5 5ce12abe4e281da68bea9b4d306ad14e
BLAKE2b-256 3d43036b8664804ff0ace9a8ff3400f90b92ebdc3c35d6c7dc82d98fb84e79d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page