Some javascript/style in this post has been disabled (
why?)
Hi list,
I come back to make a feedback.
I am writing a plugin which load data from a csv file and then
* write a shapefile
or
* write the data in a postgis table
To choose one manner or the other, I use this code:
#shapefile
mylayer = QgsVectorLayer("test.shp"), "test", "ogr")
myprovider = mylayer.getDataProvider()
Or
#postgis table
uri = QgsDataSourceURI()
uri.setConnection("localhost", "5432", "aware", "postgres",
"tikpv")
uri.setDataSource("public", "import_all", "wkb_geometry","")
pglayer = QgsVectorLayer(uri.uri(), "import_parcelle",
"postgres")
myprovider = pglayer.getDataProvider()
So basically, I just change the value of "myprovider" in order to save
the data in a shapefile or in a postgis table
Then, I create a list of features (one feature per line of my original
csv file) with
list_feat.append(feat)
And I add all the features in myprovider like this :
myprovider.addFeatures(list_feat) #list_fet is my list of
features
Both methods work well BUT I have a big speed issue with the postgis
way.
My csv file has about 3000 lines and 35 columns. So it is a big set of
data.
With the shapefile method, the process lasts about 5 seconds
With the postgis method, the process lasts about 10 minutes ! ( the
postgres.exe process uses 100% processor )
When I use ogr2ogr to import the shapefile into postgis, it lasts only
3 secondes
Have anyone an idea of what is wrong with my postgis method ?
Thanks in advance
Michael
Michaël Douchin a écrit :
Ok Martin,
Thanks a lot, I tried and it worked well
Martin Dobias a écrit :
On Tue, Mar 4, 2008 at 6:11 PM, Michaël Douchin
[hidden email] wrote:
When I load the plugin, I get this error :
Traceback (most recent call last):
File "C:/Program Files/Quantum
GIS_092_pre/./python/plugins\cematrace\cematrace.py", line 471, in
traitement
pglayer = QgsVectorLayer(uri.text(), "import_parcelle", "postgres")
AttributeError: text
Hi,
I'm sorry, the example code was wrong. The method is named uri() and
not text(). I've also corrected the example on wiki.
Bye
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer