Spaces:
Runtime error
Runtime error
File size: 809 Bytes
ed86a97 | 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 35 36 37 | """Initialize database tables for the configured DATABASE_URL."""
import os
from pathlib import Path
from dotenv import load_dotenv
def _mask_db_url(url: str) -> str:
if not url:
return "(not set)"
if "@" not in url:
return url
scheme, rest = url.split("//", 1)
creds, host = rest.split("@", 1)
if ":" in creds:
user, _ = creds.split(":", 1)
creds = f"{user}:****"
return f"{scheme}//{creds}@{host}"
def main() -> None:
env_path = Path(__file__).resolve().parents[1] / ".env"
load_dotenv(env_path)
db_url = os.getenv("DATABASE_URL", "")
print(f"Initializing database at: {_mask_db_url(db_url)}")
from src.db import init_db
init_db()
print("Database initialization complete.")
if __name__ == "__main__":
main()
|