Sunday, 4 November 2018

How to catch PostgreSQL/PostGIS errors in GDAL/OGR Python bindings?


Is it possible to catch PostgreSQL output error messages in OGR after a query has failed?


For example


conn.ExecuteSQL('SELECT * FROM non_existing_table;')

In Postgres this returns an error message:


"Error: relation 'non_existing_table' does not exist."


In ogr we get the standard:


"Error: current transaction is aborted, commands ignored until end of transaction block"

It would be a bonus if we could catch/parse the Postgres error message. I suspect this is a bit of a long-shot given what I've read about SWIG/CPL, but worth asking to see if anyone's got ideas. Ideally this would be in Python, but I'll take C/C++ comments as well!


Thanks.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...