Hello,
I have been following this advice on creating psql backups and am having trouble getting the command to run inside a python script. The following works fine when I directly put it into a bash console:
pg_dump --host='username_from_db_tab.postgres.pythonanywhere-services.com' --port='port_from_db_tab' --username=super --format=c --file=pgbackup`date +%F-%H%M`.dump stackuprisk_production
However when I run this using os.system() from inside a script like this:
os.system("pg_dump --host='username_from_db_tab.postgres.pythonanywhere-services.com' --port='port_from_db_tab' -- username=super --format=c --file=pgbackup`date +%F-%H%M`.d")
I get the following error:
pg_dump: [archiver (db)] connection to database "super" failed: FATAL: database "super" does not exist 256
I suppose there is another step needed to connect to the db from the python interpreter?
Thank you