Commit ab57756b authored by pitchum's avatar pitchum

Fix undefined symbol: sqlite3_spatialite_init

Spatialite module name has changed in Debian stretch.
This commit implements auto-detection on first connection to sqlite DB.
parent 1a4d8553
......@@ -18,6 +18,10 @@ On a Debian Jessie system, do:
apt install sqlite3 libspatialite-dev build-essential python-dev
On a Debian Stretch system, do:
apt install sqlite3 libsqlite3-mod-spatialite build-essential python-dev
Preferably in a virtualenv, run:
pip install -r requirements.txt
......@@ -34,10 +34,21 @@ def create_app(config={}):
with app.app_context():
@event.listens_for(db.engine, "first_connect")
def connect(sqlite, connection_rec):
sqlite.execute('select load_extension("libspatialite")')
current_app.spatialite_modulename = 'libspatialite'
except Exception as e:
sqlite.execute('select load_extension("mod_spatialite")')
current_app.spatialite_modulename = 'mod_spatialite'
@event.listens_for(db.engine, "connect")
def connect(sqlite, connection_rec):
sqlite.execute('select load_extension("")')
sqlite.execute('select load_extension("%s")' % current_app.spatialite_modulename)
app.session_interface = sess
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment