[Qgis-developer] conflict between Qt QSqlDatabase and PyQGis QgsDataSourceURI with spatialite connexion on addFeatures

PIERRE Sylvain sylvain.pierre at cg67.fr
Tue Oct 23 00:28:38 PDT 2012


Hi,

Got more information about my problem (http://lists.osgeo.org/pipermail/qgis-user/2012-October/019815.html) .
In my app I'm connecting twice to the same spatialite DB :
one to get layers ,

            uri = QgsDataSourceURI()
            uri.setDatabase( self.dirDBcanal )
            uri.setDataSource( "", layername, "GEOMETRY" )

one to get non-geographical data to display them into several Qt Widget,

        self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE")
        self.db.setDatabaseName(self.dirDBcanal)
        self.db.open()

The problem occurs when I build a model to display information in a Qtableview :
        self.mdlAOT = QtSql.QSqlRelationalTableModel(self.aotGui, self.db)

If I bypass this code I can insert data with the provider, if not I can't

I've tried to enable Sqlite share-cache mode, but with no effect

      self.db.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE=1")

May-be do I have to the same for QgsDataSourceURI ? (QgsDataSourceURI. setParam function ? but what param ?)

Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20121023/1900d199/attachment.html>


More information about the Qgis-developer mailing list