1

I'm working with PostgreSQL in QGIS and have a Python script that runs when the QGIS session starts.

Right now, the PostgreSQL connection requires authentication first, and only after that, the Python script window appears.

I would like to integrate the PostgreSQL login prompt directly into my Python startup script.

I've tried different approaches, but it seems there’s no way to trigger Python before the login dialogue. Is this actually possible?

5
  • 1
    Can you add an authentication (Data Source Manager -> Edit PostgreSQL connection)? This way you automatically connects to your database when you open QGIS. Commented Sep 23 at 5:52
  • This project will be used by multiple users. Eventually, I could implement a Python script that adds an authentication step after the first login of each new user. However, I’m not fully confident about the security implications, especially regarding how to prevent unauthorized access if this becomes necessary. Commented Sep 23 at 6:46
  • The way the authentication in QGIS works is that it is user specific and optional. So you add it in you QGIS instance with you credentials. Other users MAY add it with their credentials in their instance and if they don't, they have to type in their credentials manually everytime they start a session. So every user who needs to run the script on start up, said user also needs to implement the authentication. Commented Sep 23 at 6:55
  • I’ve been looking for solutions for the past few days, but the authentication system doesn’t seem usable in this case. I still have to enter the PostgreSQL password each time I connect. What I’m looking for is a way to integrate the PostgreSQL login into a separate window, rather than using the QGIS authentication system, which isn’t very useful here since I only have one password to provide. Commented Sep 25 at 4:47
  • I wasn't aware of some basic information. Like, when a postgreSQL table is loaded in the project, QGIS will ask during the project loading to connect to the db, in order to properly load all the layers. This is why I kept having the login window. I changed the way my project is organized, so I don't have these layers when starting QGIS anymore. This way I can have a personalized login and use it to connect to my postgreSQL DB. Commented Sep 25 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.