Bug report #18304

Python error when importing a shapefile to PostGIS in DB Manager

Added by Alfredo GarciaWoods about 6 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:-
Category:DB Manager
Affected QGIS version:3.0.0 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:no timely feedback
Crashes QGIS or corrupts data:No Copied to github as #:26195

Description

New description:

Importing vectors to PostGIS in DB Manager fails in QGIS 3 with a python error. The same error show also when clicking on the "update" button in the import dialog. Moreover seems that the source/target CRS parameters are not filled as they are in QGIS 2.18

Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\dlg_import_vector.py", line 200, in updateInputLayer
if not self.reloadInputLayer() or not self.inLayer:
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\dlg_import_vector.py", line 196, in reloadInputLayer
self.checkSupports()
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\dlg_import_vector.py", line 103, in checkSupports
self.chkGeomColumn.setEnabled(allowSpatial and hasGeomType)
TypeError: setEnabled(self, bool): argument 1 has unexpected type 'QgsVectorLayer'

Old description:
Bug in QGis 3.0.0 when trying to import a line vector layer(shp) to postgis database

To reproduce:
1)create a vector layer(shp), geometry type= line
2)connect to postgis database
3)import vector layer to postgis database (check create spatial index)

The message error is this
in DlgImportVector.checkSupports()

setEnabled(self, bool): argument 1 has unexpected type 'QgsVectorLayer'

errorShapeFileFromOgis3.0inQgis3.png - bug file created with 3.0 (32.8 KB) Alfredo GarciaWoods, 2018-03-02 02:40 PM

errorShapeFileFromOgis2.18inQgis3.png - bug file created with 2.18 (34.6 KB) Alfredo GarciaWoods, 2018-03-02 02:40 PM

importPostGisBug.png - import screen (82.5 KB) Alfredo GarciaWoods, 2018-03-02 02:45 PM

errorShapeFileFromOgis2.18inQgis3.png - shp created in qgis 2.18 (34.6 KB) Alfredo GarciaWoods, 2018-03-02 02:45 PM

errorShapeFileFromOgis3.0inQgis3.png - shp created in qgis 3.0.0 (32.8 KB) Alfredo GarciaWoods, 2018-03-02 02:45 PM

river.dbf (66 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

river.cpg (5 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

river.prj (143 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

river.qpj (257 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

river.shp (100 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

river.shx (100 Bytes) Alfredo GarciaWoods, 2018-03-02 07:37 PM

History

#1 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback

With DB Manager? Can you attach the data that does not work for you? The same data work on 2.18?

#2 Updated by Alfredo GarciaWoods about 6 years ago

Giovanni Manghi wrote:

With DB Manager? Can you attach the data that does not work for you? The same data work on 2.18?

The same procedure works with 2.18, and does not work with 3.0.0
Then I tried to test with the same data, I found that the shp file was not saved when using Qgis 3.0.0
I investigate a little bit more, and found that when I try to save the shape file using Qgis 3.0.0
The file is already there(virtually), and searching the file, using the windows explorer it is not really saved in the disk.
So, I save it in a different folder.

Test the import shape layer/file into postgis with a file created with Qgis 2.18 and 3.0.0 with the same error message.

#3 Updated by Alfredo GarciaWoods about 6 years ago

Giovanni Manghi wrote:

With DB Manager? Can you attach the data that does not work for you? The same data work on 2.18?

The same procedure works with 2.18, and does not work with 3.0.0
Then I tried to test with the same data, I found that the shp file was not saved when using Qgis 3.0.0
I investigate a little bit more, and found that when I try to save the shape file using Qgis 3.0.0
The file is already there(virtually), and searching the file, using the windows explorer it is not really saved in the disk.
So, I save it in a different folder.

Test the import shape layer/file into postgis with a file created with Qgis 2.18 and 3.0.0 with the same error message.

#4 Updated by Alfredo GarciaWoods about 6 years ago

Example of the shp created with Qgis 3.0.0 and can't be imported.
The problem is in the import, because the same created with QGis 2.18 also fails to import into postgis, in 3.0.0

#5 Updated by Giovanni Manghi about 6 years ago

  • Subject changed from Bug in QGis 3.0.0 when trying to import a line vector layer(shp) to postgis database to Python error when importing a shapefile to PostGIS in DB Manager
  • Regression? changed from No to Yes
  • Operating System deleted (Windows)
  • Priority changed from Normal to High
  • Status changed from Feedback to Open
  • Category changed from Data Provider/PostGIS to DB Manager
  • Description updated (diff)

Description and subject updated.

#6 Updated by chris Mr over 5 years ago

Giovanni Manghi wrote:

Description and subject updated.

I ran into this problem today as well. Has anyone tried with the latest qgis version? Any update on this issue?

#7 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

chris Mr wrote:

Giovanni Manghi wrote:

Description and subject updated.

I ran into this problem today as well. Has anyone tried with the latest qgis version? Any update on this issue?

I cannot replicate this anymore, at least using qgis master, please give it a try.

#8 Updated by Paolo Cavallini over 5 years ago

Could you please check again on current release? It seems to be working here.
Thanks.

#9 Updated by Nyall Dawson over 5 years ago

  • Status changed from Feedback to Closed
  • Resolution set to no timely feedback

Also available in: Atom PDF