import os from flask import Flask from flask_sqlalchemy import SQLAlchemy # Ensure the instance directory exists (relative to project root) instance_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'instance')) os.makedirs(instance_dir, exist_ok=True) # Set the correct database URI db_path = os.path.join(instance_dir, 'dashboard.db') print(f"Using database at: {db_path}") app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{db_path}' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) with app.app_context(): db.reflect() # This loads all tables from the database db.drop_all() print("Dropped all tables successfully.")