2020-01-08 21:31:00 +01:00
|
|
|
from app import db
|
|
|
|
from database.constants import DB_NAME, DB_USER, DB_PW
|
2020-01-05 02:51:14 +01:00
|
|
|
from subprocess import run
|
2020-01-05 01:00:06 +01:00
|
|
|
|
|
|
|
|
2020-01-05 02:51:14 +01:00
|
|
|
def create_database():
|
|
|
|
script = "database/mariadb_setup.sh"
|
|
|
|
output = run([script, DB_NAME, DB_USER, DB_PW])
|
|
|
|
if output.returncode != 0:
|
2020-01-05 01:00:06 +01:00
|
|
|
print("Error: couldn't create database")
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
2020-01-05 02:51:14 +01:00
|
|
|
def create_tables():
|
|
|
|
db.create_all()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
create_database()
|
|
|
|
create_tables()
|
2020-01-05 01:00:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|