I am trying to spatially enable my sqlite database:
import sqlite3
db = r'c:\temp\mydata.sqlite'
conn = sqlite3.connect(db)
conn.enable_load_extension(True)
cur = conn.cursor()
cur.execute(r"SELECT load_extension("<path>\libspatialite-4.dll");")
conn.commit()
conn.close()
del conn
Python just stops working when I run this code. It doesn't crash in windows 7 x64, it just closes. It's very strange. No error is raised.
When I run the commands directly from python.exe in the command propmpt, I see python crashing:
Am I doing anything wrong?
Best Answer
The version of
sqlite3.dll
included with Python doesn't seem to want to play nice with Spatialite. The only thing I could get to work (short of compiling everything from source) was:sqlite-dll-win32-x86-[version].zip
mod_spatialite-[version]-win-x86.7z
sqlite3.dll
that is in your Python DLLs directory, to something likesqlite3_old.dll
, so that Python will use the new one on your pathSee this blog post for more info.