Database Tools

spatialist.sqlite_util.sqlite_setup(driver=':memory:', extensions=None, verbose=False)[source]

Setup a sqlite3 connection and load extensions to it. This function intends to simplify the process of loading extensions to sqlite3, which can be quite difficult depending on the version used. Particularly loading spatialite has caused quite some trouble. In recent distributions of Ubuntu this has become much easier due to a new apt package libsqlite3-mod-spatialite. For use in Windows, spatialist comes with its own spatialite DLL distribution. See here for more details on loading spatialite as an sqlite3 extension.

Parameters:
  • driver (str) – the database file or (by default) an in-memory database

  • extensions (list) – a list of extensions to load

  • verbose (bool) – print loading information?

Returns:

the database connection

Return type:

sqlite3.Connection

Example

>>> from spatialist.sqlite_util import sqlite_setup
>>> conn = sqlite_setup(extensions=['spatialite'])