Coverage for app\db.py: 67%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-25 15:02 -0300

1"""Database module config.""" 

2from sqlmodel import Session, SQLModel, create_engine 

3 

4from app.config import get_settings 

5 

6settings = get_settings() 

7 

8engine = create_engine(settings.database_url, echo=True) 

9 

10 

11def init_db(): 

12 """Initialize database.""" 

13 SQLModel.metadata.create_all(engine) 

14 

15 

16def get_session(): 

17 """Session database.""" 

18 with Session(engine) as session: 

19 yield session