[Qgis-developer] DB Manager, spatialite 4 and Python

Ivan Minčík ivan.mincik at gmail.com
Sat Mar 29 12:35:39 PDT 2014


Hi all,
I was thinking how to improve situation with pyspatialite and spatialite 4
incompatibility. I have found that loading dynamic libspatialite module
instead pyspatialite is easier than I thought, at least in Ubuntu 12.04.

Here is working code example (python-pysqlite2 required):

from pysqlite2 import dbapi2 as sqlite3
conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
cur = conn.cursor()
cur.execute("SELECT load_extension('libspatialite.so.5')")
cur.execute("SELECT ST_Length(ST_GeometryFromText('LINESTRING(30 10,
10 30, 40 40)'))")
print cur.fetchone()[0]
conn.close()


Has anybody tried to replace pyspatialite with python-pysqlite2 and dynamic
libspatialite loading ?


-- 
Ivan Minčík
ivan.mincik at gmail.com  GPG: 0x79529A1E
http://imincik.github.io/0x79529A1E.key
ivan.mincik at gista.sk     GPG: 0xD714B02C
http://imincik.github.io/0xD714B02C.key
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140329/3d392462/attachment.html>


More information about the Qgis-developer mailing list