2

I am manually editing a Postgis layar with QGIS and would like to export these manual changes in the form of an SQL script. This way:

  • I can do it automatically next time i need to
  • it is easier to work on remote machines where i don't have QGIS

Is this possible?

2
  • What type of manual edits are you making? Spatial edits? Attribute edits? Some more details may help us provide a better answer. Aug 29, 2011 at 12:47
  • I meant spatial edits. It is easy to manually drag a line in QGIS but to repeat the exact same thing again is practically undoable.
    – mrg
    Nov 21, 2012 at 7:45

2 Answers 2

5

Don't know how to do it specifically for QGIS, but when I want to know what queries an application is executing, I turn on logging on the database. If you are only interested in seeing update/inserts you can do this:

ALTER DATABASE mygisdb SET log_statement='mod';

Read: http://www.postgresql.org/docs/9.0/static/runtime-config-logging.html for more details

Then check your logs after your QGIS change and copy the statements.

Logs are usually kept in pg_log folder (check your postgresql.conf to be sure).

3
  • This sounds like a very good idea. I will have to try this to see if this works. I will get back here after i have tried your suggestion.
    – mrg
    Aug 29, 2011 at 17:11
  • I tried it and it worked! Thank you for your good answer!
    – mrg
    Aug 30, 2011 at 10:43
  • It might be handy to know that the output found in the logfile needs a bit of editing before you can use it in an SQL script. Make sure you add E before the bytestring and replace all occurrences of \ with \\ as in: geomfromwkb(E'\\001\\002\\000...
    – mrg
    Aug 30, 2011 at 17:29
0

I have no idea to do it automatically with QGIS but I know that you can retrieve WKT geometry just with copy and past data from QGIS to text file. You need to write the SQL part (*UPDATE FROM XXXX SET the_geom='' WHERE id='YY'* ou INSERT).

Hope it helps,

Y.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.