File size: 928 Bytes
0e45ab7 9c2b104 0e45ab7 9c2b104 0e45ab7 9c2b104 0e45ab7 9c2b104 0e45ab7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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.")
|