import os from config import Config def get_sqlite_path(): db_uri = Config.SQLALCHEMY_DATABASE_URI if db_uri.startswith("sqlite:///"): filename = db_uri.replace("sqlite:///", "") # PRIORIDAD: carpeta instance/ instance_path = os.path.join(os.getcwd(), "instance", filename) if os.path.exists(instance_path): return instance_path # Si no existe en instance/, intenta raĆ­z return os.path.join(os.getcwd(), filename) raise RuntimeError("Unsupported DB URI") if __name__ == "__main__": DB_FILE = get_sqlite_path() print("DB FILE PATH:", DB_FILE) if os.path.exists(DB_FILE): print("Removing existing database:", DB_FILE) os.remove(DB_FILE) else: print("No existing database found:", DB_FILE) print("Running seed.py to recreate DB and initial data...") from seed import seed seed() print("Done.")