Bug report #14981

Import of Shapefile to Geopackage-Database in DB-Manager fails

Added by Flo Ju over 7 years ago. Updated over 6 years ago.

Category:DB Manager
Affected QGIS version:2.14.1 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:22930


If I try to import a SHP into an existing Geopackage-Database with DB-Manager the following error occurs:
"Error 11 Connection to database failed" - although the GPKG-Database is connected in DB-Manager and existing data viewable.
Screenshot attached.

2016-06-08_10_33_06-DB_Manager_-___Remote.jpg (122 KB) Flo Ju, 2016-06-08 01:39 AM

qgis.gif - Example of failing import. (1.12 MB) Tim Sutton, 2016-07-06 12:35 AM

error.png (142 KB) Admire Nyakudya, 2016-11-11 01:26 AM


#1 Updated by Salvatore Larosa over 7 years ago

  • Category set to Data Provider/SpatiaLite

#2 Updated by Matthias Kuhn over 7 years ago

  • Category changed from Data Provider/SpatiaLite to DB Manager

This does not seem to be related to spatialite. If it's about the target provider it should be gdal/ogr, was this the intention, and if yes, do you have any hints what might be wrong?

#3 Updated by Even Rouault over 7 years ago

There are 2 issues :
- DlgImportVector.accept() calls QgsVectorLayerImport.importLayer() with providerName = 'spatialite', but the spatialite provider doesn't support GPKG. This could be tweaked to route to the ogr provider
- However QgsOgrProvider::createEmptyLayer() (and QgsOgrProvider constructor) doesn't accept database style URI (with dbname, table parameters), and doesn't accept creating a new layer into an existing datasource. I'm not sure adding this capability in feature freeze is appropriate ?

#4 Updated by Tim Sutton about 7 years ago


I could replicate the issue here as well although I am not sure if it is the same error others get.

See attached gif for the workflow I tried:

2016-07-06T08:30:05    1    Traceback (most recent call last):
              File "/Users/timlinux/dev/cpp/QGIS/build-QGIS-QGIS_Build_Kit-Default/output/python/plugins/db_manager/db_tree.py", line 103, in newConnection
                self.mainWindow.invokeCallback(item.addConnectionActionSlot, index)
              File "/Users/timlinux/dev/cpp/QGIS/build-QGIS-QGIS_Build_Kit-Default/output/python/plugins/db_manager/db_manager.py", line 288, in invokeCallback
                callback(self.tree.currentItem(), self.sender(), self, *params)
              File "/Users/timlinux/dev/cpp/QGIS/build-QGIS-QGIS_Build_Kit-Default/output/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 102, in addConnectionActionSlot
            AttributeError: 'function' object has no attribute 'emit'

I think that since GeoPackage support is 'the way of the future' we should fix this if we can before the release (I would not consider it a new feature). In the DB Manager the database connection group is 'Spatialite/GeoPackage' which implies for the user that GeoPackage imports should work.

#5 Updated by Anita Graser about 7 years ago

Tim Sutton wrote:

In the DB Manager the database connection group is 'Spatialite/GeoPackage' which implies for the user that GeoPackage imports should work.

+1 It does not work in the 2.16 release now.

Is there any other way within QGIS to add a table to an existing GeoPackage?

(Is this issue really Windows-only?)

#6 Updated by Admire Nyakudya almost 7 years ago

I have created a geopackage vector using ogr and when I try to add a layer in dbmanager I also encounter connection to database failed.
System: ubuntu 16.04
Qgis: 2.18

#7 Updated by Giovanni Manghi over 6 years ago

  • Resolution set to duplicate
  • Status changed from Open to Closed

replaced by #16295

Also available in: Atom PDF