feat: implement full API - all admin/user routes, RBAC, sync service, collector, MySQL config, superadmin hanbin credentials
9d66536 Download scripts/init_db.py from binhugg2/api: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/binhugg2/api/resolve/main/scripts/init_db.py
- Command line
-
hf download hf://spaces/binhugg2/api/scripts/init_db.py
-
curl -L -o init_db.py https://huggingface.co/spaces/binhugg2/api/resolve/main/scripts/init_db.py
811 Bytes
| import asyncio | |
| import importlib | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from app.database import engine, Base, async_session | |
| async def init(): | |
| import app.models | |
| from scripts.seed_categories_sources import seed as seed_categories | |
| from scripts.seed_permissions import seed as seed_permissions | |
| from scripts.seed_roles import seed as seed_roles | |
| from scripts.create_superadmin import create_superadmin | |
| async with engine.begin() as conn: | |
| await conn.run_sync(Base.metadata.create_all) | |
| print("Tables created.") | |
| await seed_categories() | |
| await seed_permissions() | |
| await seed_roles() | |
| await create_superadmin() | |
| print("Database initialization complete!") | |
| if __name__ == "__main__": | |
| asyncio.run(init()) |