QGIS – Load data into PostGIS
March 22, 2022 By David Crowther
Question:
How can I load data into my PostGIS database?
Answer:
Why not use the Export to PostgreSQL tool available in the Processing Toolbox!
From the Processing menu choose > Toolbox > open the Database section and choose the Export to PostgreSQL menu option.

The Export to PostgreSQL Tool will open.

We will use the following settings:
Input Layer - choose the GIS file that you wish to upload – in this example UK Ceremonial Counties
Database – choose your PostGIS database Connection – this will need to have been created already
Schema – choose the Schema within your PostGIS database that you wish to upload the layer into. Here we will choose Public
Table – choose a name for the uploaded layer e.g., uk_counties or leave it blank to use the existing layer name
Primary Key Field – choose an existing field in your data to assign as the Primary Key
Geometry Column – choose a field name for the geometry column, the default will be geom

There are also some additional options that you can choose to tick and apply where needed:

If you now Run the Export to PostgreSQL Tool, the chosen GIS layer will then be uploaded and imported into the PostGIS database.

Now, within QGIS you can use the Add Layers > PostGIS option to connect to PostGIS and add your new PostGIS table –

