1

I have a spatialite database (v4.1.1 / SQlite v3.7.17) consisting of one geometry table and several attribute tables linked to the geometry table by foreign keys. I want to export all tables to a postgis (v2.1.3) / postgresql database (v9.3). Using ogr2ogr and the following code:

ogr2ogr -append -lco GEOMETRY_NAME=geom -lco SCHEMA=public -f PostgreSQL PG:"dbname=... host=... port=... user=... password=..." -a_srs EPSG:4269 c:\MyFile.sqlite

I am able to export the geometry table, but not the attribute tables. Any idea why? Is there an option of the ogr2ogr function I am missing?

1

What you need is a general GDAL config option "SQLITE_LIST_ALL_TABLES"

You can test what effect it has by comparing these two commands:

ogrinfo db.sqlite
ogrinfo db.sqlite --config SQLITE_LIST_ALL_TABLES yes

The "list all tables" option is listing also such metadata tables which you for sure do not want to export and therefore it is better to explicitly list the tables you want to export.

This should work:

ogr2ogr -append -lco GEOMETRY_NAME=geom -lco SCHEMA=public -f PostgreSQL PG:"dbname=... host=... port=... user=... password=..." -a_srs EPSG:4269 c:\MyFile.sqlite geometry_table atttibute_table_1 attribute_table_2

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.