[Qgis-developer] Connect to Spatialite db from Pyqgis causes OperationalError: no such functions geometry constraints

Martin Dobias wonder.sk at gmail.com
Wed Mar 31 16:44:46 EDT 2010


On Wed, Mar 31, 2010 at 10:13 PM, Marcelo Reyes <reyesmarcelo at gmail.com> wrote:
> Hello,
>
> I'm currently developping a small stand alone app with qgis python bindings
> and spatialite. So far I managed to load a vector layer from de spatialite
> database, but when I try to UPDATE or INSERT anything I get the folowing
> error:
>
> OperationalError: no such functions geometry constraints
>
> I'm guessing this is because the libspatialite extension is not loaded, but
> when I try to load it using query.exec_("SELECT
> load_extension('libspatialite-1.dll')") nothing happens. I'm using QGIS
> 1.4.0-1 "enceladus" and python 2.5, using the PyQt4 modules included in
> qgis.

Do you have any reason for not using directly QGIS classes to do
updates and inserts in the spatialite?
Get QgsVectorDataProvider instance from the vector layer:
provider = layer.dataProvider()
- INSERT: provider.addFeatures(...)
- UPDATE: provider.changeAttributeValues(...) or
provider.changeGeometryValues (...)
- DELETE: provider.deleteFeatures(...)


Martin


More information about the Qgis-developer mailing list