When connecting to PostgreSQL/PostGIS using the OGR Python bindings is it possible to get non-spatial table names (i.e. OGR layers) from the connection?
Currently, doing:
conn = ogr.Open("PG: #params")
for layer in conn:
print layer.GetName()
Will only print the names of spatial tables, however I can access non-spatial tables by (for example) directly specifying the table name, e.g.:
layer = conn.GetLayerByName('non_spatial_table_name')
The OGR docs refer to the "PG_LIST_ALL_TABLES=YES" parameter, but I can't find how this links to API (let alone the Python SWIG bindings!).
Best Answer
You can execute any arbitrary SQL from the connection. For example, to get data from
spatial_ref_sys
, which is a non-spatial table: