Debian Codegraph @

tests/build_small_spatialite_db.py

raw
1 import sqlite3
2
3 # This script generates the spatialite.db file in our tests directory.
4
5
6 def generate_it(filename):
7 conn = sqlite3.connect(filename)
8 # Lead the spatialite extension:
9 conn.enable_load_extension(True)
10 conn.load_extension("/usr/local/lib/mod_spatialite.dylib")
11 conn.execute("select InitSpatialMetadata(1)")
12 conn.executescript("create table museums (name text)")
13 conn.execute("SELECT AddGeometryColumn('museums', 'point_geom', 4326, 'POINT', 2);")
14 # At this point it is around 5MB - we can shrink it dramatically by doing thisO
15 conn.execute("delete from spatial_ref_sys")
16 conn.execute("delete from spatial_ref_sys_aux")
17 conn.commit()
18 conn.execute("vacuum")
19 conn.close()
20
21
22 if __name__ == "__main__":
23 generate_it("spatialite.db")