updated solution

This commit is contained in:
2025-07-31 16:37:54 +03:00
parent 756f9052b5
commit c8bbbebb48
31 changed files with 199 additions and 190 deletions

21
models/clear_db.py Normal file
View File

@@ -0,0 +1,21 @@
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.")