Open bernardotorres opened 9 years ago
So, some findings: It doesn't matter on spatialite version. I've tested with spatialite 4.2.0 with the same result. What I have done to run was execute this before querying for SpatialIndex table:
self.con.enable_load_extension(True)
self.cur.execute("SELECT load_extension('/usr/local/lib/mod_spatialite.so.7');")
The problem is defining the lib location for each installation. An option would be another initialization parameter for DB().
Other solution would be to skip loading this table. A simple "if" would suffice. The class already has a exclude_system_tables option, but is disregarded because this loading is made in:
self._create_sqlite_metatable()
Depending on your idea on how to tackle the problem I can produce a pull request accordingly.
Same problem here 3 years later: my short-term solution was to add an initialization parameter extensions=[]
. If this is not empty, it triggers self.con.enable_load_extension(True)
and then iterates over extensions for ext in extensions: self.con.load_extension(ext)
. Pretty useful when subclassing DB:
class SpatialDB(db.DB):
def __init__(self, filename):
db.DB.__init__(self, filename=filename, dbtype="sqlite", extensions=["mod_spatialite"])
It has problem reading properties of SpatialIndex - VirtualSpatialIndex virtual table even though I can run the same SQL in the CLI.
In ipython: