pythonwindowssqlitespatialite

Use spatialite extension for SQLite on Windows


I know that this has been asked in some similar ways before. However, all questions I found on this dealt with some very specific system setups which were not applicable for me (because so is mine).

System:

How can I activate the spatialite extension for the ´sqlite3´ module?

What I tried (the way that other people in similar questions say it works):

Then, running

import sqlite3

conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
conn.execute('SELECT load_extension("libspatialite-2.dll")')

gives

conn.execute("SELECT load_extension('libspatialite-2.dll')")
sqlite3.OperationalError: The specified module could not be found.

What more can I try to make this work?


Solution

  • you probably don't have the folder in which libspatialite-2.dll is placed in your PATH. Perhaps you can add the folder from within your Python script (I don't know any Python). Or else you could add it from the Windows properties interface.

    BTW you are using a very old version of spatialite: have a look here for newer versions: https://www.gaia-gis.it/fossil/libspatialite/index