1

I would like to write Python scripts that can load Spatialite across Linux platforms and Spatialite versions. For Spatialite versions lower than 4.2, I can use this:

from pysqlite2 import dbapi2 as sql
con = sql.connect("mydb.sqlite")
con.enable_load_extension(True)
con.execute('SELECT load_extension("libspatialite.so");')

For Spatialite versions >= 4.2, I must change the last line to:

con.execute('SELECT load_extension("mod_spatialite");')

Neither is cross compatible for me. Is there a solution for cross compatibility I am missing? I could invoke try and except using both load_extension commands, but I would prefer a one-line solution. Does one exist?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.