pysxgeo
Description
pysxgeo is an API that provides access to Sypex Geo (2.2) databases (country and city). The databases provides an information about geolocation by ip-address. For information about databases please visit sypexgeo.net.
Requirements
Python 3.x
Sypex Geo City (or Country) database
Installation
$ pip install pysxgeo
Usage
Some examples:
>>> from pysxgeo import sxgeo
>>>
>>> ip = '77.236.97.247'
>>> db = '/path/to/db' # City or Country
>>> # AVAILABLE MODES: SXGEO_FILE, SXGEO_MEMORY, SXGEO_BATCH
>>> info = sxgeo.SxGeo(db_file=db, mode=sxgeo.SXGEO_BATCH)
>>> info.get_city(ip, full=True)
{'country': {'id': 56, 'lon': 10.5, 'lat': 51.5,
'name_en': 'Germany', 'iso': 'DE', 'name_ru': 'Германия'},
'region': {'id': 2861876, 'iso': 'DE-NW',
'name_en': 'Land Nordrhein-Westfalen',
'name_ru': 'Северный Рейн-Вестфалия'},
'city': {'id': 2831105, 'lon': 6.36667, 'name_ru': 'Sonsbeck',
'name_en': 'Sonsbeck', 'lat': 51.61667}}
>>> info.get_country(ip)
'DE'
>>> info.get_country_id(ip)
56
>>> # Quick usage. The answer depends of your database choice.
>>> info.get(ip)
{'city': {'name_en': 'Sonsbeck', 'lon': 6.36667,
'name_ru': 'Sonsbeck', 'id': 2831105, 'lat': 51.61667},
'country': {'iso': 'DE', 'id': 56}},
>>> # Get coordinates tuple(latitude, longitude)
>>> info.get_coords() # For the last ip
(51.61667, 6.36667)
>>> info.get_coords(ip) # For the new ip
(51.61667, 6.36667)
>>> # Get db info:
>>> info.about()
Notes
Processing of the DB with charset ‘utf-8’ is faster than processing DB with charset ‘cp1251’.
Metadata
Release files for pysxgeo 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysxgeo-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Release files / pysxgeo-0.0.3-py3-none-any.whl
| Download URL | pysxgeo-0.0.3-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e3a95668fb2088d8a4e67687bdc81fe6fe73f80f22f64776319fff97741792a
|
|
BLAKE2b-256 checksum How to use checksums |
f05cab212a83fee8ede408d3e48abedd9f5757b4fd1689576e2b864404385998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pysxgeo 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.