|
@@ -34,10 +34,21 @@ def create_app(config={}):
|
|
|
db.init_app(app)
|
|
|
|
|
|
with app.app_context():
|
|
|
+ @event.listens_for(db.engine, "first_connect")
|
|
|
+ def connect(sqlite, connection_rec):
|
|
|
+ sqlite.enable_load_extension(True)
|
|
|
+ try:
|
|
|
+ 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'
|
|
|
+ sqlite.enable_load_extension(False)
|
|
|
+
|
|
|
@event.listens_for(db.engine, "connect")
|
|
|
def connect(sqlite, connection_rec):
|
|
|
sqlite.enable_load_extension(True)
|
|
|
- sqlite.execute('select load_extension("libspatialite.so")')
|
|
|
+ sqlite.execute('select load_extension("%s")' % current_app.spatialite_modulename)
|
|
|
sqlite.enable_load_extension(False)
|
|
|
|
|
|
app.session_interface = sess
|