|
from dialog.settings import Settings |
|
from sqlalchemy import create_engine |
|
from sqlalchemy.orm import Session, DeclarativeBase |
|
|
|
engine = create_engine(Settings().DATABASE_URL) |
|
|
|
class Base(DeclarativeBase): |
|
pass |
|
|
|
def get_session(): # pragma: no cover |
|
with Session(engine) as session: |
|
yield session |
When making plugins using dialog, it's useful to leverage from dialog-lib modules, which are available during development since dialog-lib is distributed package. But since dialog itself is not a package, this function get_session, for example, can not be inspected or accessed (specially when pytests runs and look at available modules). It's only accessed when we run the application using dialog's image.
I think I'd be a good idea to move this functionality to dialog-lib to make it available in the distributed package.
dialog/src/dialog/db/__init__.py
Lines 1 to 12 in 833ae63
When making plugins using dialog, it's useful to leverage from dialog-lib modules, which are available during development since dialog-lib is distributed package. But since dialog itself is not a package, this function
get_session, for example, can not be inspected or accessed (specially when pytests runs and look at available modules). It's only accessed when we run the application using dialog's image.I think I'd be a good idea to move this functionality to dialog-lib to make it available in the distributed package.