[GIS] Loading mod_spatialite using sqlite3 for Python in Windows

pythonspatialitesqlitewindows

I have been successfully using the mod_spatialite extension for sqlite in Linux for a while now, but a client wants an application that relies on mod_spatialite to work in Windows.

I have extracted the required dlls to a folder that I have added to the Windows PATH variable. This lets me start a standalone version of sqlite3.exe and load mod_spatialite with SELECT load_extension('mod_spatialite');. However, when trying to load this extension in Python using the sqlite3 module, I get an error:

sqlite3.OperationalError: The specified procedure could not be found

In linux, I can simply use SELECT load_extension('/path/to/mod_spatialite');, but sqlite3 gives the same 'specified procedure could not be found' error.

Am I missing something here?

Best Answer

The problem was with the version of Sqlite Python was using. The sqlite3.dll shipped with ArcGIS's Python 2.7.5 could not load the mod_spatialite extension.

So solve the issue, I simply downloaded the .dll for the newest version of sqlite3 (available here) and then replaced the sqlite3.dll found in C:\Python27\ArcGIS10.2\DLLs with the new one.