Python code for GeoIP2 webservice client and database reader
geoip2.database.Reader
now supports being used in a with
statement
(PEP 343). (PR from Nguyễn Hồng Quân. GitHub #29)geoip2.records.Location
class has been updated to add attributes for the average_income
and population_density
fields provided by the Insights web service.is_anonymous_proxy
and is_satellite_provider
properties on
`geoip2.records.Traits`` have been deprecated. Please use our GeoIP2 Anonymous IP database to determine whether an IP address is used by an anonymizing service.mmap
module,
the file mode will be used by default. You can explicitly set the mode using
the mode
keyword argument with the MODE_AUTO
, MODE_MMAP
,
MODE_MMAP_EXT
, MODE_FILE
, and MODE_MEMORY
constants exported by
geoip2.database
.geoip2.database.Reader
class now has an anonymous_ip()
method which
returns a geoip2.models.AnonymousIP
object.__repr__
and __eq__
methods to the model and record classes
to aid in debugging and using the library from a REPL.geoip2.webservice.Client
now takes an optional timeout
parameter. (PR from arturro. GitHub #15)city_isp_org()
and omni()
methods
have been removed.geoip2.database.Reader
lookup methods (e.g., city()
,
isp()
) now raise a TypeError
if they are used with a database that
does not match the method. In particular, doing a city()
lookup on a
GeoIP2 Country database will result in an error and vice versa.metadata()
method has been added to the geoip2.database.Reader
class. This returns a maxminddb.reader.Metadata
object with information
about the database.city_isp_org
and omni
methods on
geoip2.webservice.Client
should be considered deprecated. The city
method now provides all of the data formerly provided by city_isp_org
,
and the omni
method has been replaced by the insights
method.
Note: In v2.1 of the web service, accuracy_radius
,
autonomous_system_number
, and all of the confidence
values were
changed from unicode to integers. This may affect how you use these values
from this API.