[Qgis-user] Storing data to postgis from Qgis
Brent Wood
pcreso at pcreso.com
Tue Dec 30 12:20:33 PST 2014
David,
Given your data is managed in Postgres, what you are doing seems (from my limited understanding) to contravene good data management practice. It is more a data management than (Q)GIS operation.
Ideally you never replicate records in a database - this leads to data inconsistencies and update/maintenance problems. The approach generally used (apart from data warehousing cases) is to use views to create virtual tables, so your selects (which do not require QGIS to make - just to visualise) can be applied to create a view on your source table containing the desired records.
You could wrap this functionality up in a script (language of your choice) to facilitate the creation & modification of such views, such as the addition of new records to an existing view - either by extending the where clause, or adding new record using "union". A stored QGIS project opening such views as layers will automatically pick up any changes made which impact on the view contents.
Cheers
Brent Wood
From: Jan Michálek <godzilalalala at gmail.com>
To: David Kramer <davidk at gmail.com>
Cc: qgis-user <qgis-user at lists.osgeo.org>
Sent: Wednesday, December 31, 2014 2:24 AM
Subject: Re: [Qgis-user] Storing data to postgis from Qgis
In db manager you can import data in new table or add features to an existing table.
Or you can add empty column to a table, select in qgis desktop, open atribute table, display selected features on top and edit empty column by your atributes.
2014-12-30 6:10 GMT+01:00 David Kramer <davidk at gmail.com>:
Leknin,
Thanks for the reply. I've followed your recipe and indeed I can paste my selected features as a new memory layer (thanks Jan) and then import the layer via db manager into postgis. This is tremendously useful, but is not quite what I'm looking for.
I don't really want to create a new table, I really want to just select a few fields out of my newly selected layer and save those as a row in an already created table. For example, let's assume I have a table that lists franchises the states that they do business in and the columns:
'Franchise Name' | 'States' | 'geom'===================================Alice's Restaurant | "NY, NJ, PA" | ...
Joe's Burgers | "CA, NV, OR" | ...
To add a new row to the table I'd like to go into qgis, select the states for a franchise (from a layer of states), save that as a memory layer. Then I'd like to have a save function which allows me to enter the franchise name. It would save only the name, the states and the geometry as a row in the table.
Make sense? Is this possible from the GUI or do I need to write a plugin in pyQGIS?
ThxDavid
_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141230/ac00f867/attachment.html>
More information about the Qgis-user
mailing list