[gdal-dev] GPKG to PG single transaction, different schemas
Even Rouault
even.rouault at spatialys.com
Tue May 14 09:22:51 PDT 2024
Le 14/05/2024 à 17:30, Matteo Ghetta via gdal-dev a écrit :
> Hi all,
>
> I've a geopackage with many layers (in the following example let's
> pretend just 2) that I want to import in a single transaction
> (important!) into a PG database.
>
> GPKG and PG table names are the same, but it can happen that the
> tables are in different schemas. I couldn't find the correct flags
> combination to specify the destination schema.table_name.
>
> With the following command features of first_table are appended to the
> second_table table:
>
> ogr2ogr --debug ON -f PostgreSQL "PG:host=localhost user=matteo
> password=my_pws dbname=test" -append /home/matteo/export_db.gpkg
> first_schema.first_layer second_schema.second_layer
>
> same with the -nln option:
>
> ogr2ogr --debug ON -f PostgreSQL "PG:host=localhost user=matteo
> password=my_pws dbname=test" -append /home/matteo/export_db.gpkg
> first_layer -nln first_schema.first_layer second_layer -nln
> second_schema.second_layer
There's no formal concept of schema in GeoPackage. You can't use -nln
multiple times. It works only when importing a single layer
Yes, you'll likely have to use ogr2vrt
(https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/samples/ogr2vrt.py)
and rename manually the layers
And add "-ds_transaction -gt unlimited" to make sure everything is
imported in the same transaction
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the gdal-dev
mailing list