View raw

1 # -*- mode: python; -*- 2 3 import os 4 from app import create_app, db 5 6 7 app = create_app() 8 DB_NAME = "mdl.db" 9 app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + DB_NAME 10 db_path = f"app/{DB_NAME}" 11 12 13 if os.path.exists(db_path): 14 os.remove(db_path) 15 print(f"Existing database {db_path} has been deleted successfully.") 16 else: 17 print(f"Database {db_path} does not exist yet, creating now.") 18 19 with app.app_context(): 20 print(f"Creating database {db_path}...") 21 db.create_all() 22 23 24 print(f"Database {db_path} created successfully.") 25