вот команда дампа требует пароля. Написил такого рода приложение: def dump_table(host_name, database_name, user_name, database_password, dump_file):
command = 'pg_dump -U {0} -W -h {1} --clean {2} > {3}'\
.format(user_name, host_name, database_name, dump_file)
p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
return p.communicate('{}\n'.format(database_password))
def main():
dump_table(DB_host, DB_name, DB_user, DB_pass, DB_file)
if __name__ == "__main__":
main() Но оно вылетает с ошибкой File "backup_script.py", line 24, in <module>
main()
File "backup_script.py", line 20, in main
dump_table(DB_host, DB_name, DB_user, DB_pass, DB_file)
File "backup_script.py", line 16, in dump_table
return p.communicate('{}\n'.format(database_password))
File "/usr/lib/python3.5/subprocess.py", line 1072, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.5/subprocess.py", line 1700, in _communicate
input_view = memoryview(self._input)
TypeError: memoryview: a bytes-like object is required, not 'str' В чем может быть проблема ?
`'pg_dump -U {0} -W -h {1} --clean {2} > {3}'\ .format(user_name, host_name, database_name, dump_file) `
Обсуждают сегодня