Bug report #17991

Importing into gpkg error

Added by Paolo Cavallini over 6 years ago. Updated over 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:DB Manager
Affected QGIS version:3.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25887

Description

dropping a shp with a strange prj (attached, recognized as EPSG:102091) into a gpkg results in an error [0].
What is worse, the db becomes apparently unusable.

[0]

An error has occurred while executing Python code:

RuntimeError: In ExecuteSQL(): sqlite3_prepare_v2(SELECT srid FROM
gpkg_spatial_ref_sys WHERE table_name = 'animals'):   no such column: srid
Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line
438, in rowCount
    self._refreshIndex(parent, True)
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line
489, in _refreshIndex
    if item.populate():
  File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line
180, in populate
    tables = database.tables()
  File "/usr/share/qgis/python/plugins/db_manager/db_plugins/plugin.py",
line 510, in tables
    tables = self.connector.getTables(schema.name if schema else None,
sys_tables)
  File
"/usr/share/qgis/python/plugins/db_manager/db_plugins/gpkg/connector.py",
line 274, in getTables
    vectors = self.getVectorTables(schema)
  File
"/usr/share/qgis/python/plugins/db_manager/db_plugins/gpkg/connector.py",
line 346, in getVectorTables
    srid = self._fetchOne('SELECT srid FROM gpkg_spatial_ref_sys WHERE
table_name = %s' % self.quoteString(lyr.GetName()))
  File
"/usr/share/qgis/python/plugins/db_manager/db_plugins/gpkg/connector.py",
line 104, in _fetchOne
    sql_lyr = self.gdal_ds.ExecuteSQL(sql.encode('UTF-8'))
  File "/usr/lib/python2.7/dist-packages/osgeo/gdal.py", line 1966, in
ExecuteSQL
    return _gdal.Dataset_ExecuteSQL(self, *args, **kwargs)
RuntimeError: In ExecuteSQL(): sqlite3_prepare_v2(SELECT srid FROM
gpkg_spatial_ref_sys WHERE table_name = 'animals'):
  no such column: srid

animals.zip (150 KB) Paolo Cavallini, 2018-01-29 08:58 AM

History

#1 Updated by Paolo Cavallini over 6 years ago

  • Assignee set to Alessandro Pasotti

#2 Updated by Alessandro Pasotti over 6 years ago

This works correctly in the main QGIS browser.
It is probably a DB manager specific issue.

#3 Updated by Alessandro Pasotti over 6 years ago

The same layer, which is correctly imported and displayed when opened from the main QGIS browser, does not open from DB manager because SRS is undefined (-1)

#4 Updated by Paolo Cavallini over 6 years ago

  • Assignee deleted (Alessandro Pasotti)

#5 Updated by Paolo Cavallini over 6 years ago

  • Affected QGIS version changed from master to 3.0.0

#6 Updated by Alessandro Pasotti over 6 years ago

  • Pull Request or Patch supplied changed from No to Yes
  • Affected QGIS version changed from 3.0.0 to master
  • Assignee set to Alessandro Pasotti
  • Status changed from Open to In Progress

PR https://github.com/qgis/QGIS/pull/6452

might be a partial fix: tested only d&d of sigle and multi-part shapefiles to gpkg and postgres.

#7 Updated by Alessandro Pasotti over 6 years ago

Sorry, wrong bug.

#8 Updated by Alessandro Pasotti over 6 years ago

  • Pull Request or Patch supplied changed from Yes to No
  • Status changed from In Progress to Open
  • Assignee deleted (Alessandro Pasotti)

#9 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

Please check if this issue is still valid on QGIS 3.4.5 or 3.6.

#10 Updated by Paolo Cavallini over 5 years ago

  • Affected QGIS version changed from master to 3.6.0
  • Status changed from Feedback to Closed
  • Resolution set to fixed/implemented

Also available in: Atom PDF