I had to backup a PostGIS model in a geopackage and I wonder how to load a non-spatial table, aka a table with NO geometry_column.


Just had to write None instead of the geometry_column name in the setDataSource method.

uri = QgsDataSourceUri()
uri.setConnection("MyServerAdress", "5432", "myBase", "user", "pass")
uri.setDataSource(schema, table, None)
layer = QgsVectorLayer(uri.uri(False), table, "postgres")

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.