pysqlite: what a big confusion ....

252 views
Skip to first unread message

a.furieri

unread,
Apr 20, 2012, 8:49:56 AM4/20/12
to SpatiaLite Users
just a quick update about pysqlite (Python SQLite connector)

from pysqlite2 import dbapi2 as db
con = db.connect(':memory:')
con.enable_load_extension(True)
con.load_extension('libspatialite.so')
con.execute('select InitSpatialMetadata()')
for row in con.execute('select * from spatial_ref_sys'):
print row

the above code snippet nicely works on both Debian and
Mint (and I easily imagine on Ubuntu as well).
so it looks like there is absolutely no real reason suggesting
to use the specialized pyspatialite connector on these systems.

anyway I've got an unexpected failure on Fedora 16:
"enable_load_extension is not supported"
and I've got a second failure on Windows, using the Python
console shipped within the OsGeo4W supplied most recent QGIS
nightly build: "unknown package: pysqlite2"

support for the pysqlite2 connector apparently seems to be
rather whimsical and erratic, and not at all consistent
between different platforms ... a really unpleasant condition.

bye Sandro

Volker Froehlich

unread,
Apr 21, 2012, 4:05:06 AM4/21/12
to spatiali...@googlegroups.com

Concerning Fedora:

Fedora's Python 2.7 is built not to allow loading SQLite extensions.
Pysqlite2 is also deprecated, as Python 2.5 integrated a module called
sqlite3.

I created a ticket, asking to allow loading extensions. Please look
there for details.

https://bugzilla.redhat.com/show_bug.cgi?id=814905

> bye Sandro
>


Lokkju Brennr

unread,
Apr 21, 2012, 5:04:35 AM4/21/12
to spatiali...@googlegroups.com
The entire reason I wrote pyspatialite in the first place is that many
distros package libsqlite/pysqlite with load_extensions disabled - as
of last year, this included Ubuntu 10.04 LTS.

It would be lovely if packagers would just enable it...

Loki

> --
> You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
> To post to this group, send email to spatiali...@googlegroups.com.
> To unsubscribe from this group, send email to spatialite-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spatialite-users?hl=en.
>

Goyo

unread,
Apr 22, 2012, 6:58:47 PM4/22/12
to spatiali...@googlegroups.com
El sábado, 21 de abril de 2012 11:04:35 UTC+2, Loki escribió:
The entire reason I wrote pyspatialite in the first place is that many
distros package libsqlite/pysqlite with load_extensions disabled - as
of last year, this included Ubuntu 10.04 LTS.

It would be lovely if packagers would just enable it...

Absoluyely agree. But I don't think that's going to be the case of ubuntu 12.04:

>>> import sqlite3
>>> con = sqlite3.connect(':memory:')
>>> con.enable_load_extension(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'

So thank you very much for this module which make our lifes easier.

Goyo

a.fu...@lqt.it

unread,
Apr 23, 2012, 4:43:50 AM4/23/12
to spatiali...@googlegroups.com
> The entire reason I wrote pyspatialite in the first place is that
> many distros package libsqlite/pysqlite with load_extensions disabled
> -
> as of last year, this included Ubuntu 10.04 LTS.
>

good new: pyspatialite will be soon supported on Debian: Ubuntu GIS
packages simply are clones of the ones available on Debian

I personally feel that pyspatialite is a nice connector, effectively
"filling the hole" and allowing to bypass the many inconsistencies
existing between different platforms.

Anyway a potential design flaw exists: AFAIK the pyspatialite's own
build script implicitly attempts to statically link both libsqlite and
libspatialite (libspatialite-amalgamation).

This is absolutely fine if you intend to use Python only for
self-standing
apps: but unhappily many users use Python mainly as an engine for QGIS
own plugins.
But in this complex scenario a real risk exists to end up using *three*
separate sqlite/spatialite libraries, maybe of different versions (one
linked to the the QGIS core itself, another linked to GDAL/OGR, and a
third one linked to pyspatialite).

As first hand field experience tells, this one is a sure recipe for
disaster.
Any possible effort aimed to always ensure linking the "system-wide"
dynamic
libraries (shared objects, DLLs or whatever else) is strongly
suggested,
both on Linux and Windows.

bye Sandro

--
Il messaggio e' stato analizzato alla ricerca di virus o
contenuti pericolosi da MailScanner, ed e'
risultato non infetto.

Reply all
Reply to author
Forward
0 new messages