Spaces:
Sleeping
Sleeping
| """ | |
| SQLite Database Initialization | |
| Creates all tables for Mirchi Trading Application | |
| """ | |
| import asyncio | |
| import sys | |
| import os | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from sqlalchemy.ext.asyncio import create_async_engine | |
| from app.core.database import Base | |
| from app.core.config import settings | |
| async def init_database(): | |
| """Initialize SQLite database with all tables""" | |
| print("=" * 60) | |
| print("MIRCHI TRADING - SQLite Initialization") | |
| print("=" * 60) | |
| print(f"\nDatabase URL: {settings.DATABASE_URL}") | |
| print("\nCreating tables...") | |
| engine = create_async_engine(settings.DATABASE_URL, echo=True) | |
| async with engine.begin() as conn: | |
| # Create all tables from models (SQLAlchemy handles SQLite compatibility) | |
| await conn.run_sync(Base.metadata.create_all) | |
| print("\n" + "=" * 60) | |
| print("✅ DATABASE INITIALIZED!") | |
| print("=" * 60) | |
| print("\nNo default mirchi types - create your own via the UI.") | |
| print("\nYou can now run the application with:") | |
| print(" uvicorn app.main:app --reload") | |
| await engine.dispose() | |
| if __name__ == "__main__": | |
| asyncio.run(init_database()) | |