summaryrefslogtreecommitdiff
path: root/initialize_database.py
blob: 7b7226bf6ba75c06d3e97e42a602c45eaec030e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- mode: python; -*-

import os
from app import create_app, db


app = create_app()
DB_NAME = "mdl.db"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + DB_NAME
db_path = f"app/{DB_NAME}"


if os.path.exists(db_path):
    os.remove(db_path)
    print(f"Existing database {db_path} has been deleted successfully.")
else:
    print(f"Database {db_path} does not exist yet, creating now.")

with app.app_context():
    print(f"Creating database {db_path}...")
    db.create_all()


print(f"Database {db_path} created successfully.")
Copyright 2019--2024 Marius PETER