mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 18:03:31 +01:00
db.Session: Add
Add database session API to db. This is a breaking change, because from this commit on, a session object has to be passed to every query. This commit also removes any reference to Cmds / App objects. An instantiated database object can be worked with outside of an App. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
841b5a3391
commit
495cebd769
5 changed files with 56 additions and 31 deletions
|
|
@ -24,8 +24,8 @@ class Queries(abc.ABC): # export
|
|||
|
||||
# -- implement API
|
||||
|
||||
def _run(self, *args, **kwargs) -> QueryResult:
|
||||
return self.__func(*args, **kwargs)
|
||||
def _run(self, session, *args, **kwargs) -> QueryResult:
|
||||
return self.__func(session, *args, **kwargs)
|
||||
|
||||
def _register(self):
|
||||
raise Exception('Can\'t call register on this object')
|
||||
|
|
@ -57,10 +57,6 @@ class Queries(abc.ABC): # export
|
|||
def db(self) -> DataBase:
|
||||
return self.__db
|
||||
|
||||
@property
|
||||
def app(self) -> Cmds:
|
||||
return self.__db.app
|
||||
|
||||
def load(self, modules: list[str], cls=QueryBase):
|
||||
for path in modules:
|
||||
slog(INFO, f'Loading modules from {path}')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue