Hi, looks like you didn't initialize QGIS. See PyQGIS CookBook [0]
[0] http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications 2012/10/19 PIERRE Sylvain <[email protected]>: > Hello list, > > The following code is running perfectly inside Qgis (1.7.2) from the python > console : > > from PyQt4 import QtCore, QtGui > uri = QgsDataSourceURI() > uri.setDatabase( "C:/APPLI_PDT/CANAL_DEV/bd_canal.sqlite") > uri.setDataSource( "", "AOT_POINT", "GEOMETRY" ) > layer = QgsVectorLayer( uri.uri(), "AOT", "spatialite" ) > provider = layer.dataProvider() > feat = QgsFeature() > geometry = QgsGeometry() > feat.setAttributeMap({1:QtCore.QVariant(5)}) > feat.setGeometry(geometry.fromPoint(QgsPoint(990650,110807))) > (res, outFeats) = provider.addFeatures( [ feat ] ) > print str(res) > > But outside it’s failing (in my app build with python, PyQt and PyQgis). > > Res is set to false, and no row was insert. > > I’ve spent lots of time with Google, but didn’t found anything… -- Alexander Bruy _______________________________________________ Qgis-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-user
