Initialize database tables and enable WAL mode for SQLite.
()
| 50 | |
| 51 | |
| 52 | async def init_db(): |
| 53 | """Initialize database tables and enable WAL mode for SQLite.""" |
| 54 | async with engine.begin() as conn: |
| 55 | await conn.run_sync(Base.metadata.create_all) |
| 56 | if "sqlite" in settings.database_url: |
| 57 | await conn.execute(text("PRAGMA journal_mode=WAL")) |
| 58 | await conn.execute(text("PRAGMA busy_timeout=30000")) |
| 59 | |
| 60 | |
| 61 | async def close_db(): |
no test coverage detected