Siddharaj Shirke
v1 completed successfully
67c8aca
raw
history blame contribute delete
872 Bytes
import os
from backend.db.database import engine
from backend.db import models
def reset_db():
print("Attempting to reset database...")
try:
# Drop all tables
models.Base.metadata.drop_all(bind=engine)
print("Dropped all tables.")
# Recreate all tables
models.Base.metadata.create_all(bind=engine)
print("Recreated all tables with new schema.")
# Alternatively, try to delete the file if it exists
db_path = "loan_system.db"
if os.path.exists(db_path):
try:
os.remove(db_path)
print(f"Deleted {db_path} file.")
except Exception as e:
print(f"Could not delete file (might be locked): {e}")
except Exception as e:
print(f"Error during reset: {e}")
if __name__ == "__main__":
reset_db()