Bug report #11759

Python error when running "Import Vector into PostGIS database (available connections)"

Added by Filipe Dias almost 10 years ago. Updated almost 10 years ago.

Status:Closed
Priority:Normal
Assignee:Giovanni Manghi
Category:Processing/GDAL
Affected QGIS version:master 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 #:19991

Description

When I try to run this algorithm, this message appears:

Algorithm Import Vector into PostGIS database (available connections) starting...
string index out of range See log for more details

Log:

Uncaught error while executing algorithm
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 212, in execute
self.processAlgorithm(progress)
File "/usr/share/qgis/python/plugins/processing/algs/gdal/ogr2ogrtopostgislist.py", line 252, in processAlgorithm
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]
File "/usr/share/qgis/python/plugins/processing/algs/gdal/GdalUtils.py", line 147, in escapeAndJoin
if s0 != '-' and ' ' in s:
IndexError: string index out of range

points.tar.bz2 (155 KB) Filipe Dias, 2015-01-22 01:08 PM

History

#1 Updated by Filipe Dias almost 10 years ago

The "Import Vector into PostGIS database (new connection)" works as expected

#2 Updated by Filipe Dias almost 10 years ago

  • Subject changed from Python erro when running "Import Vector into PostGIS database (available connections)" to Python error when running "Import Vector into PostGIS database (available connections)"

#3 Updated by Olivier Dalang almost 10 years ago

Confirmed here, but it's a bit strange since I get the error when trying on a remote postgis server, but not on the localhost... But none of them has spaces in the database name nor in the password.

#4 Updated by Filipe Dias almost 10 years ago

The DB I tried with is also local and the name has no spaces or special characters.

#5 Updated by Giovanni Manghi almost 10 years ago

  • Status changed from Open to Feedback

I'm not able to replicate the issue with my own local/remote connections, so I need more help in understanding what is the factor (what input) causing this error.

#6 Updated by Giovanni Manghi almost 10 years ago

  • Priority changed from High to Normal

#7 Updated by Filipe Dias almost 10 years ago

Olivier, I've sent Giovanni the details of my connection and he was not able to reproduce the bug. Can you provide more details on how you are experiencing the bug?

#8 Updated by Pedro Venâncio almost 10 years ago

Hi Filipe,

I also can not reproduce here (locally or remotely).

Can you share a sample dataset that is failing with you?

#9 Updated by Filipe Dias almost 10 years ago

Thanks for taking the time to look at this.

I got this error with every shapefile I tried. I've attached an example.

#10 Updated by Giovanni Manghi almost 10 years ago

Filipe Dias wrote:

Thanks for taking the time to look at this.

I got this error with every shapefile I tried. I've attached an example.

please try on another pc, or just a VM.

#11 Updated by Pedro Venâncio almost 10 years ago

Filipe Dias wrote:

Thanks for taking the time to look at this.

I got this error with every shapefile I tried. I've attached an example.

Hi Filipe,

I tried on Xubuntu 12.04, Lubuntu 14.04 and Win OSGeo4W64, without problems.

#12 Updated by Jérôme Guélat almost 10 years ago

Same problem here with a local PostGIS server (Windows 7, PostgreSQL 9.3.4, PostGIS 2.1.2, QGIS 2.7, 64-bit). However everything is fine with another remote server running with Ubuntu...

#13 Updated by Pedro Venâncio almost 10 years ago

Jérôme Guélat wrote:

Same problem here with a local PostGIS server (Windows 7, PostgreSQL 9.3.4, PostGIS 2.1.2, QGIS 2.7, 64-bit). However everything is fine with another remote server running with Ubuntu...

Hi,

I don't know if that has some influence, but all database servers that I've tested are in Linux (one of them with PostgreSQL 9.1.14 and PostGIS 2.0.3).

#14 Updated by Filipe Dias almost 10 years ago

I'm on ubuntu 14.04, using Postgresql 9.3.5, Postgis 2.1.3

#15 Updated by Filipe Dias almost 10 years ago

I just tested this tool on Ubuntu 12.04 + postgresql 9.1.14 + postgis 2.1.3 (in the same computer, different partition) and got the same error.

#16 Updated by Filipe Dias almost 10 years ago

In my case the problem was the field "Database" was blank (in postgis connection properties). Once I filled it the tool worked as expected.

I understand this field is mandatory, but note that it is possible to import shapefiles into a Postgis DB using DB Manager with this field blank.

#17 Updated by Jérôme Guélat almost 10 years ago

I think you found something interesting! The password field in the PostGIS connection properties was empty in my case (because I don't want a password for local connections). The tool worked as expected as soon as I added some characters in the password field.

#18 Updated by Giovanni Manghi almost 10 years ago

  • Priority changed from Normal to Low
  • Status changed from Feedback to Open

This tool makes really sense only if ALL connection informations are filled, otherwise you need to use the other version, the one that allows you to fill the connection data instead of using an already defined one. Sure I can try to catch this error and throw a message.

#19 Updated by Jérôme Guélat almost 10 years ago

I agree with you about the database field, but I think an empty password field is nothing unusual if you configure PostgreSQL to accept local connections without password. You could check if the password field is empty and then use some "fake" password which will be accepted anyway.

#20 Updated by Filipe Dias almost 10 years ago

This is tool is only available in QGIS Master and 3 different people have already stumbled upon this. It's therefore likely more people will encounter this bug when QGIS 2.8 is released. I would suggest adding a clear warning to the help file or, as Giovanni says, try to catch this error and throw a warning.

This is tool is way too good and doesn't deserve to have users frustrated over a matter as simple as this.

#21 Updated by Giovanni Manghi almost 10 years ago

  • Priority changed from Low to Normal

#22 Updated by Giovanni Manghi almost 10 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed/implemented

Also available in: Atom PDF