postgres dump不能正常工作,我通过eclipse和linux(ubuntu)后台操作系统运行下面的python程序。你知道吗
问题是eclipse挂起了,跟踪信息以及备份文件都是空的。你知道吗
import os
import subprocess
if __name__ == '__main__':
print "test hello"
localhost = 'localhost'
port = '5432'
role = 'serverdb_user'
dump_dir = '/home/backupfile/'
db_username = 'empserverdb_user'
db_names = 'emp1'
try:
bkp_file = 'backup1'
file_path = os.path.join(dump_dir, bkp_file)
print file_path
dumper_cmd = ['pg_dump', '-h', localhost, '-p', port, '-U', db_username, '--role', role, '-W', '-Fc', '-v', '-f', file_path, db_names]
print dumper_cmd
subprocess.check_output(dumper_cmd)
except subprocess.CalledProcessError, ex:
print("Couldn't back up database {0}: pg_dump returned {1} with output {2}".format(db_names, ex.returncode, ex.output))
except Exception, ex:
print("Couldn't backup database {0}: unexpected error {1}".format(db_names, ex))
这个问题可以通过向env分配密码来解决。以及人们对postPostgres Dump is strucked in eclipse, language used is python的建议
相关问题 更多 >
编程相关推荐