python:subprocess.Popen和postgresql驱使我屁股

时间:2015-07-18 00:31:25

标签: python postgresql

一个非常简单的小安排:

psql = '/usr/bin/psql'
database = 'mydb'
script = 'foo.sql'
p = subprocess.Popen([psql, '-d', database, '-f', script], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
exit = p.returncode

但它失败了,说FATAL: database "user" does not exist好像它在用户user下运行而忽略了-d标志。

是什么给出了?

0 个答案:

没有答案