]> git.ipfire.org Git - people/ms/libloc.git/blob - examples/python/create-database.py
Add a few examples that show how to use the python module
[people/ms/libloc.git] / examples / python / create-database.py
1 #!/usr/bin/python3
2
3 import location
4
5 w = location.Writer()
6
7 # Set the vendor
8 w.vendor = "IPFire Project"
9
10 # Set a description
11 w.description = "This is a geo location database"
12
13 # Add an AS
14 a = w.add_as(204867)
15 a.name = "Lightning Wire Labs GmbH"
16
17 print(a)
18
19 # Add a network
20 n = w.add_network("2a07:1c44:5800::/40")
21 n.country_code = "DE"
22 n.asn = a.number
23
24 print(n)
25
26 # Write the database to disk
27 w.write("test.db")