Bug report #14436

Failure to connect to postgres database defined as service in DB manager

Added by Admire Nyakudya over 8 years ago. Updated over 8 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Alessandro Pasotti
Category:DB Manager
Affected QGIS version:2.14.0 Regression?:No
Operating System:Ubuntu Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22415

Description

I have set-up a new database connection in QGIS that uses service connection. I can connect successfully but when I try to connect to the same database it fails to connect. The error seems to be centred on DB manager not reading the service files correctly. It reads the user-name as database name and this causes it not to connect

db_manager.png (47.5 KB) Admire Nyakudya, 2016-03-07 03:20 AM

service.png (68.5 KB) Admire Nyakudya, 2016-03-07 03:20 AM

pg_service.conf Magnifier (70 Bytes) Admire Nyakudya, 2016-03-14 02:09 AM


Related issues

Related to QGIS Application - Bug report #16626: DBManager fails to load rasters from service-only PostGIS... Closed 2017-05-26
Related to QGIS Application - Bug report #16625: DBManager fails to load raster from dbname-less connection Closed 2017-05-26
Duplicated by QGIS Application - Bug report #14208: DBManager don't use pgservice.conf Closed 2016-02-01

Associated revisions

Revision 212b125a
Added by Alessandro Pasotti over 8 years ago

[dbmanager] PG ignore env if service file is used

Fixes #14436

Funded by Boundless

Revision 0bde3574
Added by Alessandro Pasotti over 8 years ago

[dbmanager] PG ignore env if service file is used

Cherry-picked from master

Fixes #14436

Funded by Boundless

History

#1 Updated by Luigi Pirelli over 8 years ago

please check if connection is set-up correctly with the target DB name

#2 Updated by Admire Nyakudya over 8 years ago

When I click on Add postgis layers and define my service configuration I can access the database tables. It is only when I try to access the database using DB manager that it fails to connect

#3 Updated by Luigi Pirelli over 8 years ago

again... try to setup dbname in the connection con figuration. dbname is not set in the screenshot you sent.

#4 Updated by Admire Nyakudya over 8 years ago

If I define a dbname it works. But I thought the point of using service files is to have the whole database configuration defined in the service file and then just connect. So this way does it mean the port,user name,password are the only parameters that are read from the service file when using DB Manager. When using service files with the Add postgis layers you can just specify service file and no other parameters and it still works.

#5 Updated by Luigi Pirelli over 8 years ago

I don't think this is a but... but a feature request

when you add a db layer you connect to a specified db+table (otherwise default is tablename=username)... also just testing connection need a db... if not set it test on postgres db that is the administrative db always present.

if need db metadata... eg list of tables in a db, you have to connect to postgresdb and query relative tables.
if you need installed db on a remote db.

I feel that this have to be changed to feature request or removed as bug.

#6 Updated by Tim Sutton over 8 years ago

Hi Luigi. For me it is a regression - the behaviour changed from how it worked before in < 2.14 and if you are using a service file then you should not need to set the db name or other connection information since these are specified in the service file.

#7 Updated by Luigi Pirelli over 8 years ago

Sorry

I didn't know was a regression due to my lack of user experience

@Admire, just a question. your DB connection is set-up using basic authentication with user and pwd? or do you use any of the "new" authentication features storing credentials in auth-db? (settings->options->authentication).

The answer is useful to me to replicate the problem

#8 Updated by Admire Nyakudya over 8 years ago

I currently use basic authentication. I have uploaded a sample service file. [[http://www.postgresql.org/docs/9.1/static/libpq-pgservice.html]]

#9 Updated by Luigi Pirelli over 8 years ago

sorry for my late... we are really busy on testing plugins stuffs. I'll be back on this issue in some days

#10 Updated by Giovanni Manghi over 8 years ago

  • Priority changed from High to Severe/Regression
  • Target version changed from Version 2.14 to Version 2.16

#11 Updated by Alessandro Pasotti over 8 years ago

  • Assignee changed from Luigi Pirelli to Alessandro Pasotti
  • Status changed from Open to In Progress

#12 Updated by Anonymous over 8 years ago

  • Status changed from In Progress to Closed

#13 Updated by Luigi Pirelli over 8 years ago

tnx elpaso

#14 Updated by Paolo Cavallini over 8 years ago

Could you please backport it? Thanks.

#15 Updated by Alessandro Pasotti over 8 years ago

I've done it already with 0bde357

#16 Updated by Paolo Cavallini over 8 years ago

Great, thanks.

#17 Updated by Sandro Santilli over 7 years ago

  • Related to Bug report #16626: DBManager fails to load rasters from service-only PostGIS connections added

#18 Updated by Sandro Santilli over 7 years ago

  • Related to Bug report #16625: DBManager fails to load raster from dbname-less connection added

Also available in: Atom PDF