Uploading Geopackage contents to PostgreSQL

This tutorial shows how to import geopackges into postgres with ogr2ogr like:

ogr2ogr -f PostgreSQL "PG:dbname=gadm" DNK_adm.gpkg

Note importing into PostgreSQL like this will convert the case of the field names in your GeoPackage data to lowercase in the PostgreSQL table. To maintain case you would need to use the lco option like:

ogr2ogr -f PostgreSQL "PG:dbname=gadm" DNK_adm.gpkg -lco LAUNDER=NO

There is work ongoing in QGIS master (e.g. here and here to 'fix' the tool in QGIS (Import vector into Postgis database - ...) which generates command line parameters for OGR2OGR for you to use, specifically for Postgis, which seems to have broken with QGIS 3. I also have another pull request planned for more fixes and additional options. If you can wait a week or so, and use master, or 3 months or so and use 3.4 then that will avoid you having to input command line parameters manually, and should work for many different file formats, including geopackage.


Using the tutorial on this link it´s better add to the GDAL command line (ogr2ogr) the next options.

ogr2ogr -f PostgreSQL "PG:user=youruser password=yourpassword dbname=yourdbname" yourgeopackage.gpkg

It works for me.