最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - stdout=outfile in subprocess.run doesn't work with the shell pg_restore - Stack Overflow

programmeradmin1浏览0评论

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})
发布评论

评论列表(0)

  1. 暂无评论