jwutils: Move to jwutils -> jw.util
Move all implementation source code from the jwutils module to jw.util. For compatibility with existing Python modules, keep a thin, autogenerated compatibility shim under jwutils. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bc7652fdf9
commit
a2684dd601
1 changed files with 678 additions and 52 deletions
61
src/python/jw/util/db/query/Query.py
Normal file
61
src/python/jw/util/db/query/Query.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Any
|
||||
|
||||
import abc
|
||||
|
||||
from ...log import *
|
||||
from ...misc import load_classes
|
||||
from ...Cmds import Cmds
|
||||
from ..DataBase import DataBase
|
||||
from ..Session import Session
|
||||
from .QueryResult import QueryResult
|
||||
#from .Queries import Queries
|
||||
|
||||
class Query(abc.ABC): # export
|
||||
|
||||
def __init__(self, parent: Any) -> None:
|
||||
self.__parent = parent
|
||||
|
||||
# -- pure virtuals
|
||||
|
||||
@abc.abstractmethod
|
||||
def _run(self, session: Session, *args, **kwargs) -> QueryResult:
|
||||
raise Exception('Called pure virtual _run()')
|
||||
|
||||
@abc.abstractmethod
|
||||
def _register(self):
|
||||
raise Exception('Called pure virtual _register()')
|
||||
|
||||
@abc.abstractmethod
|
||||
def _column_names(self) -> list[str]:
|
||||
raise Exception('Called pure virtual _column()')
|
||||
|
||||
# -- used by Queries class
|
||||
|
||||
def register(self):
|
||||
return self._register()
|
||||
|
||||
# -- to be used
|
||||
|
||||
def _add(self, query_name: str, location: str, func: Any):
|
||||
return self.__parent.add(self, query_name, location, func)
|
||||
|
||||
def run(self, session: Session, *args, **kwargs) -> QueryResult:
|
||||
return self._run(session, *args, **kwargs)
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self.__parent
|
||||
|
||||
@property
|
||||
def db(self) -> DataBase:
|
||||
return self.__parent.db
|
||||
|
||||
@property
|
||||
def schema(self):
|
||||
return self.__parent.db.schema
|
||||
|
||||
@property
|
||||
def column_names(self) -> list[str]:
|
||||
return self._column_names()
|
||||
Loading…
Reference in a new issue