Download reset_db.py from ed29/xertify: direct link, hf CLI and curl.
- Browser
- Download file 928 Bytes
-
https://huggingface.co/spaces/ed29/xertify/resolve/main/reset_db.py
- Command line
-
hf download hf://spaces/ed29/xertify/reset_db.py
-
curl -L -o reset_db.py https://huggingface.co/spaces/ed29/xertify/resolve/main/reset_db.py
928 Bytes
| 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.") | |