N
N
nicolaychuchka2019-01-21 12:32:27
Python
nicolaychuchka, 2019-01-21 12:32:27

How to connect to database via subprocess.Popen()?

windows 7, visual studio 2017, PostgreSQL 11, Python 3.6.
I'm trying to connect to the database:

args = [ "C://Program files/Postgresql/11/bin/psql.exe", "-d Test", "-U postgres"]
process = subprocess.Popen(args, stdout = subprocess.PIPE)
data = process.communicate()
print(data)

The command runs, it asks for a password, when I enter the password, it outputs:
psql: IMPORTANT: the user "postgres" is not authenticated (by password)
(b'', None)
If you run the appropriate command from the console and enter the same password, everything enters normally.
I tried to set trust in the config so that it would not ask for a password at all, I get the following error:
psql: IMPORTANT: the role "postgres" does not exist (b'', None)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question