PostgreSQL Geopackage – Uploading Geopackage Contents to PostgreSQL

geopackageogrogr2ogrpostgispostgresql

As a bit of background, we are looking to transition away from the use of shapefiles. We've already started using Geopackages for desktop work (QGIS / ArcGIS) but often have a requirement to upload data to our PostgreSQL databases.

I'm aware that you are able to upload Geopackage content to Postgres using QGIS but wondering if there are any commandline utilities similar to shp2pgsql for uploading geopackages or tables in geopackages to Postgres? I'm assuming possibly ogr2ogr but can't find the documentation.

Best Answer

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