db.py 328 B

12345678910111213
  1. from tortoise import Tortoise, run_async
  2. from config import config
  3. import models
  4. async def init_db():
  5. await Tortoise.init(
  6. db_url=f"postgres://{config.DB_USER}:{config.DB_PASSWORD}@localhost:5432/{config.DB_NAME}",
  7. modules={"models": ["models"]},
  8. )
  9. await Tortoise.generate_schemas()