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.

Load the database
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import location
>>> d = location.Database("/usr/share/location/database.db")
Search for an Autonomous System by Name
>>> for i in d.search_as("Lightning Wire Labs"):
...   print(i)
AS204867 (Lightning Wire Labs GmbH)
Lookup an IP Address
>>> n = d.lookup("")
>>> n
>>> n.asn
>>> n.country_code