[Qgis-user] Editing dbf attributes via Python Console

maning sambale emmanuel.sambale at gmail.com
Mon Nov 3 01:21:01 PST 2008


Alex,

Thank you for the sqlite tip for sure I will test them out.  But for
now dbf is still what we have.  Any other tips?

cheers,
maning

On 11/3/08, Alex Mandel <tech_dev at wildintellect.com> wrote:
> maning sambale wrote:
>> Here's my python console challenge for QGIS.
>>
>> I need to edit the dbf attributes of a GRASS vector in QGIS.  I
>> usually load grass vectors in QGIS (via GRASS plugin).
>> For editing attributes of the vector dbf, I use openoffice dbase.  The
>> process goes like this:
>>
>> 1. Interactively select the vector polygons using the "select feature".
>> 2. Display the attribute table.
>> 3. Edit the selected attributes in OpenOffice
>> 4. Save dbf file in Openoffice.
>> 5. After a couple of edits, re-start QGIS.  (I does not automatically
>> "refresh" when the attributes were saved in OOO)
>>
>> Now for the challenge I want to be able to do this with Python
>> Console.  Basically I select the polygons with the "Select feature"
>> And use the console to change the dbf attributes of the selected feature.
>>
>> Any tips?
>
> It would be much easier if you used the sqlite backend for GRASS.
> Then in python there are any number of sqlite connectors(ADODB,pysqlite)
> and a nifty firefox plugin.
>
> 1st way:
> Select a feature, based on the feature id run a select query and return
> the values of that to a box. When done changing values in your edit
> boxes hit save. The save command runs an Update Query on the changed
> fields of your selected attribute. Or a delete followed by insert query.
>
> 2nd way:
> Use something like SQL Alchemy to treat each selected feature as an
> object and change the value of the property on exit from each text box.
>
>
> The best approach is to start by writing a PyQt app that allows you to
> see results from an sqlite table and edit. Once you do that integrate it
> with QGIS using visual map ques like a select feature to pass the select
> to the PyQt app.
>
> Alex
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>


-- 
|---------|----------------------------------------------------------|
| __.-._  |"Ohhh. Great warrior. Wars not make one great." -Yoda     |
| '-._"7' |"Freedom is still the most radical idea of all" -N.Branden|
|  /'.-c  |Linux registered user #402901, http://counter.li.org/     |
|  |  /T  |http://esambale.wikispaces.com|
| _)_/LI
|---------|----------------------------------------------------------|



More information about the Qgis-user mailing list