I'm curious to know why the option stdout=outfile in subprocess.run doesn't work with the shell pg_resotre. However, the output of the shell psql is indeed redirected to the output file that I indicated. What I've missed? Python version: 3.9.21
with open("stdout.log", "w") as outfile:
subprocess.run(['/usr/bin/pg_restore', '-w', '-v', '-U', user, '-h', host, '-F', 'd', '-j', '3', '-d', db, directory], stdout=outfile, text=True, env={'PGPASSFILE': pgpassfile})