import subprocess
import argparse

parser = argparse.ArgumentParser()

parser.add_argument("action", type=str, help="dump | restore")
parser.add_argument("fileName", type=str, help="nom du fichier dump")
args = parser.parse_args()

if args.action == "dump":
    process=subprocess.Popen(["pg_dump", "-h", "database", "-d", "school", "-U", "postgres", "-p", "5432", "-Fc", "-f", args.fileName + ".dmp"])
    process.wait()
elif args.action == "restore":
    process=subprocess.Popen(["pg_restore", "--clean", "-h", "database", "-d", "school", "-U", "postgres", args.fileName + ".dmp"])
    process.wait()
