libloc comes with native Python bindings which
are used by its main command-line tool
location
.
They are the most advanced bindings as they support reading
from the database as well as writing to it.
>>> import location
>>> d = location.Database("/var/lib/location/database.db")
>>> for i in d.search_as("Lightning Wire Labs"):
... print(i)
...
AS204867 - Lightning Wire Labs GmbH
>>> n = d.lookup("81.3.27.38")
>>> n
<location.Network 81.3.0.0/18>
>>> n.asn
24679
>>> n.country_code
'DE'