Disable error message and add prints for restore_sql_file
parent
75deaf7c26
commit
b116accb6d
|
@ -14,9 +14,15 @@ create_cmd = "mysql -h " + config[group]["host"] + " -u " + config[group]["user"
|
|||
restore_cmd = "mysql -h " + config[group]["host"] + " -u " + config[group]["user"] + " -p" + config[group]["password"] + " " + config[group]["database"] + " < data/external/rapids_example.sql"
|
||||
|
||||
try:
|
||||
subprocess.run(checkdb_cmd.split(), check = True)
|
||||
print("Checking if " + config[group]["database"] + " database exists")
|
||||
subprocess.run(checkdb_cmd.split(), check = True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError:
|
||||
print(config[group]["database"] + " database does not exist")
|
||||
print("Creating " + config[group]["database"] + " database")
|
||||
os.system(create_cmd)
|
||||
print(config[group]["database"] + " database created")
|
||||
print("Restoring rapids_example.sql")
|
||||
os.system(restore_cmd)
|
||||
print("rapids_example.sql restored in " + config[group]["database"] + " database")
|
||||
else:
|
||||
raise ValueError(config[group]["database"] + " DB already exists.")
|
||||
raise ValueError(config[group]["database"] + " DB already exists")
|
||||
|
|
Loading…
Reference in New Issue