1

I'm writing a quick Python script to bulk export from PosgtreSQL materialized view (PostGIS geometry) to ESRI FileGDB and ogr2ogr (I'm using the one in OSGeo4W through Python subprocess module) is throwing an error

ERROR 1: ERROR:  relation "my_schema_name.my_TABLE_name" does not exist

The name is just an example. I want to underline that the view has upper letters, but I'm passing the argument double quoted like this table_name = '"my_schema_name.my_TABLE_name"'. Is that correct?

I have no problem exporting from normal tables that the view is based on.

Does ogr2ogr read materialized view at all?

  • 5
    Correct SQL syntax is "my_schema_name"."my_TABLE_name". Do you see your materialized view in the geometry_columns? If not you may need to do it manually postgis.net/docs/…. – user30184 Jul 1 at 10:25
  • Yep, my bad. Wrong quoting. It's like you wrote. In this particular case you can even skip quoting my_schema_name, because it only contains lower case ASCII and just quote "my_TABLE_name". – pg85 Jul 1 at 10:56
2

The short answer is: Yes! ogr2ogr has no problem reading materialized views.

As user30184 pointed, my issues were caused by quoting errors. The correct Python code should be like this:

table_name = '"my_schema_name"."my_TABLE_name"'

Notice, double quotes around both, schema and table name, and single quotes wrapping whole string.

  • If you answer you own question, please provide complete answer, not just references to helpful comments from others. – TomazicM Jul 1 at 11:31
  • 1
    Well, that was a silly problem to begin with, but you are right. How about now? – pg85 Jul 2 at 15:51
  • Yes, now answer stands on it's own. And by the way, you can accept your own aswer so that it will be obvious that problem has been solved. – TomazicM Jul 2 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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