IP addresses can be looked up using the country and city methods. Instances of this class provide a reader for the GeoIP2 database format. Reader ( fileish: Union, locales: Optional] = None, mode: int = 0 ) ¶ GeoIP2 Database Reader ¶ class geoip2.database. enterprise method to do a lookup in the Enterprise database > response = reader. Reader ( '/path/to/GeoIP2-Enterprise.mmdb' ) as reader : > # Use the. You should use the same object > # across multiple requests as creation of it is expensive. > import geoip2.database > # This creates a Reader object. Please > # note that Insights is not supported by the GeoLite2 web service. AsyncClient ( 42, 'license_key' ) as client : > # Replace "city" with the method corresponding to the web service > # that you are using, i.e., "country", "city", or "insights". Set the "host" keyword argument to "" to use the > # GeoLite2 web service instead of the GeoIP2 web service.
GEOIP2 MAXMIND LICENSE
> # > # Replace "42" with your account ID and "license_key" with your license > # key. If you are using multiple event > # loops, you must ensure the object is not used on another loop. > import asyncio > import geoip2.webservice > async def main (): > # This creates an AsyncClient object that can be reused across > # requests on the running event loop. Client ( 42, 'license_key' ) as client : > # Replace "city" with the method corresponding to the web service > # that you are using, i.e., "country", "city", or "insights". > # Replace "42" with your account ID and "license_key" with your license > # key. import geoip2.webservice > # This creates a Client object that can be reused across requests.