db_connection
zeus.optimizer.batch_size.server.database.db_connection
Managing database connection.
Heavily inspired by https://praciano.com.br/fastapi-and-async-sqlalchemy-20-with-pytest-done-right.html and https://medium.com/@tclaitken/setting-up-a-fastapi-app-with-async-sqlalchemy-2-0-pydantic-v2-e6c540be4308
DatabaseSessionManager
Session manager class.
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
__init__
__init__(host, engine_kwargs=None)
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
25 26 27 28 29 30 |
|
close
async
close()
Close connection.
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
32 33 34 35 36 37 38 39 |
|
connect
async
connect()
Connect to db.
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
session
async
session()
Get session from session maker.
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
get_db_session
async
get_db_session()
Get db session from session manager. Used with fastapi dependency injection.
Source code in zeus/optimizer/batch_size/server/database/db_connection.py
76 77 78 79 |
|