Skip to main content

API to access data from Sypex Geo IP database files from your Python code

Project description

http://github.com/idlesign/pysyge

LBC Python 2

release lic

What’s that

pysyge is an API to access data from Sypex Geo IP database files from your Python code.

For more information about Sypex Geo databases and their features please visit http://sypexgeo.net.

Direct DB link that might became broken over time:

Requirements

  • Python 2.7+, 3.5+

Attention

  1. This version of pysyge works with Sypex Geo DB version 2.2 or above.

The structure of a dictionary returned by GeoLocator.get_location() was preserved in a backward compatible manner as much as possible, yet it’s advised to update your code to use data from info sub dictionary.

  1. This version of pysyge works with UTF-8 Sypex Geo Databases. Texts returned by pysyge are UTF-8.

Quickstart

Download Geo IP database file from http://sypexgeo.net/ (example below uses SxGeoCityMax.dat file).

Application sample

# Import all we need from pysyge module.
from pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY

# Create GeoLocator object to access API
# from 'SxGeoCityMax.dat' using fast memory mode.
geodata = GeoLocator('SxGeoCityMax.dat', MODE_BATCH | MODE_MEMORY)

# Let's get some meta information.
print('DB version %s (%s)' % (geodata.get_db_version(), geodata.get_db_date()))

# Request geo information for 77.88.21.3 IP address.
# Getting detailed information, including region info.
location = geodata.get_location('77.88.21.3', detailed=True)

# Print out some lyrics.
# Most interesting data is under `info` in `city`, `country` and `region` dictionaries
print('%s (%s) calling. All the circuits are busy.' % (
    location['info']['city']['name_en'], location['info']['country']['iso']))

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

pysyge-1.0.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

pysyge-1.0.0-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pysyge-1.0.0.tar.gz.

File metadata

  • Download URL: pysyge-1.0.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pysyge-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40f3225ceb5c028f17cc05cde18f7c1e3e197ba922666cc58bf710e1ef8c9d99
MD5 f442f05048e9358655e4a65b942dc6f1
BLAKE2b-256 7ab41019fe768992d2f25d9a428c0dff3010585f125d4aa4d1d9632c34c25407

See more details on using hashes here.

File details

Details for the file pysyge-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pysyge-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pysyge-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 863f9c94d0c56a1ae37f7e3813b12acc64226704ca42135ba333db6da56ee5be
MD5 aecb0e0d922f3cad9246935b7acad658
BLAKE2b-256 df708db8c026d907eb7ceae02eb21261c43e3b542d3f3b566c73dab0ddfa6a63

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