0

I am somewhat new to python and I am trying to automate my database systems. Is there a way to have python send commands to a macbook terminal. Specifically I want to send this command to the terminal to backup the database.

Thanks in advance

backup.pg_dump --file 
"/Users/john/Dropbox/__Mag_bus/backups/analyze_stats_critical_files_only_2020-10- 
21.dump" --host "localhost" --port "5432" --username "john" --no-password --verbose -- 
format=c --blobs --table  "__magazine_cover_prices" --table "__prospects" --table  
"__recommender_crosses" --table "__pricing_options" "analyze_stats"
OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
ja11946
  • 157
  • 1
  • 2
  • 13

1 Answers1

0

Use os.system().

from os import system
system("""backup.pg_dump --file 
"/Users/john/Dropbox/__Mag_bus/backups/analyze_stats_critical_files_only_2020-10- 
21.dump" --host "localhost" --port "5432" --username "john" --no-password --verbose -- 
format=c --blobs --table  "__magazine_cover_prices" --table "__prospects" --table  
"__recommender_crosses" --table "__pricing_options" "analyze_stats" """)
Seth
  • 2,049
  • 1
  • 5
  • 21