Windows 7, Visual Studio 2017, PostgreSQL 11, Python 3.6.

Trying to dump the database:

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

The command is executed, it requests a password, I enter the password, it displays an error, in the screenshot.

It is noteworthy that if from the console to call this command, everything happens as it should, through psycopg2 also connect to the database normally.

Console error

Closed due to the fact that off-topic participants 0xdb , aleksandr barakin , Enikeyschik , LFC , entithat Jan 24 at 12:35 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - 0xdb, Enikeyschik, LFC, entithat
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • text information is better to attach as text: a) easier to read; b) can be copied; c) the search works. You can correct the question text by clicking below to edit the question text - aleksandr barakin pm

1 answer 1

Try this:

 args = ["C://Program files/Postgresql/11/bin/psql.exe", "-d", "Test", "-U", "postgres"] ... 

PS note: psql.exe said that he was given the username " postgres" (with a space in the beginning)

  • Yes, there really is a space, but since you have already tried it, it displays an empty window, no errors, this is when calling psql. When pg_dump is called, a console appears (b '', None) and that's it. - Nixmist
  • ibb.co/kg8P3Tw - Nixmist
  • @ SergeyNikolaychuk, try for debugging, specify the password in the args arguments - MaxU
  • Honestly google how to pass the password through the psql arguments, did not find anything sensible, it was through a variable environment, but I did not understand how to include it in args. - Nixmist
  • @ SergeyNikolaychuk, stackoverflow.com/questions/2893954/… - MaxU