

If the address is not in the database, exception will be On the record class will have a null value. The database does not contain the requested information, the attributes This model in turn contains multiple record classes,Įach of which represents part of the data returned by the database. If the request succeeds, the method call will return a model class for You then call the methodĬorresponding to the specific database, passing it the IP address you want First, youĬreate a reader object, specifying a file name. Once created, the Reader is safe to use for lookups from multiple threads.

If youre performing multiple lookups, its most efficient to create one Reader and reuse it. Create a Reader for looking up IP addresses in a GeoIP2/GeoLite2 database file. The basic API for this class is the same for every database. initialize(database:, locales: en, mode: MaxMind::DB::MODEAUTO) Reader. IP addresses can be looked up using the database specific methods. Ip_address – an IP address in the standard string notation metadata ( ) → of this class provide a reader for the GeoIP2 database format. Reader ( database: Union, mode: int = 0 ) ¶ The bit size of a record in the search tree. A database with a value of “6” may supportĪ list of locale codes supported by the databse. A value of “4” means theĭatabase only supports IPv4. The IP version of the data in a database. Type:Ī map from locales to text descriptions of the database. Type:Ī string identifying the database type, e.g., “GeoIP2-City”. The Unix epoch for the build time of the database. The minor version number of the binary format used when creating the The major version number of the binary format used when creating the Metadata for the MaxMind DB reader binary_format_major_version ¶ This module contains the pure Python database reader and related classes.

Ip_address – an IP address in the standard string notation get_with_prefix_len ( ip_address: Union ) → Tuple, int] ¶ Return the record for the ip_address in the MaxMind DB

close ( ) → None ¶Ĭloses the MaxMind DB file and returns the resources to the system get ( ip_address: Union ) → Union ¶ IPĪddresses can be looked up using the get method. Instances of this class provide a reader for the MaxMind DB format. This error is thrown when unexpected data is found in the database. This returns a tuple containing the recordįollowed by the network prefix length associated with the record. If you wish to also retrieve the prefix length for the record, use the That IP address, the method will return None. If the database does not contain a record for The method will return theĬorresponding values for the IP address from the database (e.g., a dictionaryįor GeoIP2/GeoLite2 databases). To look up an IPĪddress, use the get method on this object. The open_database function returns a Reader object. The caller may close theįile descriptor immediately after the Reader object is created. Sure that the file descriptor gets closed properly. NOTE: When using MODE_FD, it is the caller’s responsibility to be
#MAXMIND DB READER ISO#
We source things like place names, ISO codes, and other similar data from the GeoNames premium data set. Some of the data that MaxMind provides is also sourced from GeoNames.
#MAXMIND DB READER DOWNLOAD#
To use this module, you must first download or create a MaxMind DB file. This is the ID of a geographical feature (city, region, country, etc.) in the GeoNames database.
