Export a postgis table to geopackage using the database management in QGIS

988 Views Asked by At

I am working in QGIS through the DB Manager by running some spatial queries. After I create new tables with the queries I need to export the tables as new geopackages. I've tried using the Export to Vector file inside the DB Manager but I get the following error message:

Error 2 Creation of data source failed (OGR error: sqlite3_open(/Users/xxx/Documents/xxx/xxx/xxx/xxxx/xx/new_geopackage_layer.gpkg)failed: unable to open database file)

I've read a couple of posts and they said I needed to create an empty geopackage first and then export the table and save it inside the geopackage but that did not work either. When I try to save inside an existing geopackage I get an error saying:

"geopackage.gpkg already exists. Do you want to replace it? A file or folder with the same name already exists in the folder xxx Replacing it will overwrite its current contents."

If I choose to overwrite then I get a second error message saying:

" Error 1 Unable to create the datasource. /Users/xxx/Documents/xxx/xxx/xxx/xxx/xxxx/new_geopackage.gpkg exists and overwrite flag is false."

All I want is to be able to run spatial queries inside QGIS and be able to export the tables created with the queries as geopackages.

It seems that as of now I won't be able to do this from inside QGIS but instead will need to use ogr2ogr command to export to any file type.

Any help would be really appreciated. Thank you

0

There are 0 best solutions below