Spaces:
Runtime error
Runtime error
Download init_db.py from myousaf-codes/ccr-hackathon-todo: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/myousaf-codes/ccr-hackathon-todo/resolve/main/init_db.py
- Command line
-
hf download hf://spaces/myousaf-codes/ccr-hackathon-todo/init_db.py
-
curl -L -o init_db.py https://huggingface.co/spaces/myousaf-codes/ccr-hackathon-todo/resolve/main/init_db.py
687 Bytes
| """ | |
| Database initialization script for the Todo Application. | |
| This script creates all necessary tables and indexes for the application. | |
| """ | |
| import asyncio | |
| from sqlmodel import SQLModel | |
| from models import User, Task | |
| from db import engine | |
| def create_db_and_tables(): | |
| """ | |
| Creates all database tables based on SQLModel definitions. | |
| """ | |
| print("Creating database tables...") | |
| # Create all tables | |
| SQLModel.metadata.create_all(engine) | |
| print("Database tables created successfully!") | |
| print("- Users table") | |
| print("- Tasks table") | |
| print("- Indexes: tasks.user_id, tasks.completed, tasks.created_at") | |
| if __name__ == "__main__": | |
| create_db_and_tables() |