maleo-database 0.0.22__py3-none-any.whl → 0.0.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maleo/database/handlers.py +16 -9
- maleo/database/managers/__init__.py +15 -10
- maleo/database/orm/queries.py +12 -12
- maleo/database/types.py +5 -0
- {maleo_database-0.0.22.dist-info → maleo_database-0.0.24.dist-info}/METADATA +1 -1
- {maleo_database-0.0.22.dist-info → maleo_database-0.0.24.dist-info}/RECORD +9 -8
- {maleo_database-0.0.22.dist-info → maleo_database-0.0.24.dist-info}/WHEEL +0 -0
- {maleo_database-0.0.22.dist-info → maleo_database-0.0.24.dist-info}/licenses/LICENSE +0 -0
- {maleo_database-0.0.22.dist-info → maleo_database-0.0.24.dist-info}/top_level.txt +0 -0
maleo/database/handlers.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
from pydantic import BaseModel, ConfigDict, Field
|
2
|
-
from sqlalchemy.orm import DeclarativeBase
|
3
2
|
from typing import Generic, Optional, TypeVar
|
4
3
|
from .config import (
|
5
4
|
ElasticsearchConfig,
|
@@ -21,6 +20,7 @@ from .managers import (
|
|
21
20
|
SQLServerManager,
|
22
21
|
ManagerT,
|
23
22
|
)
|
23
|
+
from .types import DeclarativeBaseT
|
24
24
|
|
25
25
|
|
26
26
|
class Handler(
|
@@ -51,22 +51,29 @@ class RedisHandler(Handler[RedisConfig, RedisManager]):
|
|
51
51
|
pass
|
52
52
|
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
class MySQLHandler(Handler[MySQLConfig, MySQLManager[T]], Generic[T]):
|
54
|
+
class MySQLHandler(
|
55
|
+
Handler[MySQLConfig, MySQLManager[DeclarativeBaseT]], Generic[DeclarativeBaseT]
|
56
|
+
):
|
58
57
|
pass
|
59
58
|
|
60
59
|
|
61
|
-
class PostgreSQLHandler(
|
60
|
+
class PostgreSQLHandler(
|
61
|
+
Handler[PostgreSQLConfig, PostgreSQLManager[DeclarativeBaseT]],
|
62
|
+
Generic[DeclarativeBaseT],
|
63
|
+
):
|
62
64
|
pass
|
63
65
|
|
64
66
|
|
65
|
-
class SQLiteHandler(
|
67
|
+
class SQLiteHandler(
|
68
|
+
Handler[SQLiteConfig, SQLiteManager[DeclarativeBaseT]], Generic[DeclarativeBaseT]
|
69
|
+
):
|
66
70
|
pass
|
67
71
|
|
68
72
|
|
69
|
-
class SQLServerHandler(
|
73
|
+
class SQLServerHandler(
|
74
|
+
Handler[SQLServerConfig, SQLServerManager[DeclarativeBaseT]],
|
75
|
+
Generic[DeclarativeBaseT],
|
76
|
+
):
|
70
77
|
pass
|
71
78
|
|
72
79
|
|
@@ -167,7 +174,7 @@ class Handlers(
|
|
167
174
|
],
|
168
175
|
):
|
169
176
|
nosql: NoSQLHandlersT = Field(..., description="NoSQL handlers")
|
170
|
-
sql:
|
177
|
+
sql: SQLHandlersT = Field(..., description="SQL handlers")
|
171
178
|
|
172
179
|
|
173
180
|
HandlersT = TypeVar("HandlersT", bound=Optional[Handlers])
|
@@ -6,7 +6,6 @@ from motor.motor_asyncio import AsyncIOMotorClient
|
|
6
6
|
from pymongo import MongoClient
|
7
7
|
from redis.asyncio import Redis as AsyncRedis
|
8
8
|
from redis import Redis as SyncRedis
|
9
|
-
from sqlalchemy.orm import DeclarativeBase
|
10
9
|
from sqlalchemy import text
|
11
10
|
from typing import Generic, Optional, Type, TypeVar
|
12
11
|
from uuid import uuid4
|
@@ -44,6 +43,7 @@ from ..config import (
|
|
44
43
|
ConfigT,
|
45
44
|
)
|
46
45
|
from ..enums import Connection
|
46
|
+
from ..types import DeclarativeBaseT
|
47
47
|
from .client import (
|
48
48
|
AsyncClientT,
|
49
49
|
SyncClientT,
|
@@ -97,13 +97,10 @@ class Manager(ABC, Generic[ConfigT]):
|
|
97
97
|
pass
|
98
98
|
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, T]):
|
100
|
+
class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, DeclarativeBaseT]):
|
104
101
|
def __init__(
|
105
102
|
self,
|
106
|
-
Base: Type[
|
103
|
+
Base: Type[DeclarativeBaseT],
|
107
104
|
config: SQLConfigT,
|
108
105
|
logger: Database,
|
109
106
|
service_context: Optional[ServiceContext] = None,
|
@@ -255,19 +252,27 @@ class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT, T]):
|
|
255
252
|
await self._engine_manager.dispose()
|
256
253
|
|
257
254
|
|
258
|
-
class MySQLManager(
|
255
|
+
class MySQLManager(
|
256
|
+
SQLManager[MySQLConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
|
257
|
+
):
|
259
258
|
pass
|
260
259
|
|
261
260
|
|
262
|
-
class PostgreSQLManager(
|
261
|
+
class PostgreSQLManager(
|
262
|
+
SQLManager[PostgreSQLConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
|
263
|
+
):
|
263
264
|
pass
|
264
265
|
|
265
266
|
|
266
|
-
class SQLiteManager(
|
267
|
+
class SQLiteManager(
|
268
|
+
SQLManager[SQLiteConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
|
269
|
+
):
|
267
270
|
pass
|
268
271
|
|
269
272
|
|
270
|
-
class SQLServerManager(
|
273
|
+
class SQLServerManager(
|
274
|
+
SQLManager[SQLServerConfig, DeclarativeBaseT], Generic[DeclarativeBaseT]
|
275
|
+
):
|
271
276
|
pass
|
272
277
|
|
273
278
|
|
maleo/database/orm/queries.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
from sqlalchemy import asc, cast, desc, or_, select
|
2
|
-
from sqlalchemy.orm import
|
2
|
+
from sqlalchemy.orm import Session, aliased
|
3
3
|
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
4
4
|
from sqlalchemy.sql import Select
|
5
5
|
from sqlalchemy.types import DATE, String, TEXT, TIMESTAMP
|
@@ -11,9 +11,9 @@ from maleo.types.base.boolean import OptionalBoolean
|
|
11
11
|
from maleo.types.base.integer import OptionalListOfIntegers
|
12
12
|
from maleo.types.base.string import OptionalListOfStrings, OptionalString
|
13
13
|
from maleo.types.enums.status import OptionalListOfDataStatuses
|
14
|
+
from ..types import DeclarativeBaseT
|
14
15
|
|
15
16
|
|
16
|
-
T = TypeVar("T", bound=DeclarativeBase)
|
17
17
|
R = TypeVar(
|
18
18
|
"R", bound=Tuple[Any, ...]
|
19
19
|
) # result shape inferred from Select (tuple[...])
|
@@ -21,7 +21,7 @@ R = TypeVar(
|
|
21
21
|
|
22
22
|
def filter_column(
|
23
23
|
stmt: Select[R],
|
24
|
-
table: Type[
|
24
|
+
table: Type[DeclarativeBaseT],
|
25
25
|
column: str,
|
26
26
|
value: OptionalAny = None,
|
27
27
|
include_null: bool = False,
|
@@ -44,7 +44,7 @@ def filter_column(
|
|
44
44
|
|
45
45
|
def filter_ids(
|
46
46
|
stmt: Select[R],
|
47
|
-
table: Type[
|
47
|
+
table: Type[DeclarativeBaseT],
|
48
48
|
column: str,
|
49
49
|
ids: OptionalListOfIntegers = None,
|
50
50
|
include_null: bool = False,
|
@@ -67,7 +67,7 @@ def filter_ids(
|
|
67
67
|
|
68
68
|
def filter_timestamps(
|
69
69
|
stmt: Select[R],
|
70
|
-
table: Type[
|
70
|
+
table: Type[DeclarativeBaseT],
|
71
71
|
date_filters: Sequence[DateFilter],
|
72
72
|
) -> Select[R]:
|
73
73
|
if date_filters:
|
@@ -94,7 +94,7 @@ def filter_timestamps(
|
|
94
94
|
|
95
95
|
def filter_statuses(
|
96
96
|
stmt: Select[R],
|
97
|
-
table: Type[
|
97
|
+
table: Type[DeclarativeBaseT],
|
98
98
|
statuses: OptionalListOfDataStatuses,
|
99
99
|
) -> Select[R]:
|
100
100
|
if statuses is not None:
|
@@ -105,7 +105,7 @@ def filter_statuses(
|
|
105
105
|
|
106
106
|
def filter_is_root(
|
107
107
|
stmt: Select[R],
|
108
|
-
table: Type[
|
108
|
+
table: Type[DeclarativeBaseT],
|
109
109
|
parent_column: str = "parent_id",
|
110
110
|
is_root: OptionalBoolean = None,
|
111
111
|
) -> Select[R]:
|
@@ -122,7 +122,7 @@ def filter_is_root(
|
|
122
122
|
def filter_is_parent(
|
123
123
|
session: Session,
|
124
124
|
stmt: Select[R],
|
125
|
-
table: Type[
|
125
|
+
table: Type[DeclarativeBaseT],
|
126
126
|
id_column: str = "id",
|
127
127
|
parent_column: str = "parent_id",
|
128
128
|
is_parent: OptionalBoolean = None,
|
@@ -143,7 +143,7 @@ def filter_is_parent(
|
|
143
143
|
|
144
144
|
def filter_is_child(
|
145
145
|
stmt: Select[R],
|
146
|
-
table: Type[
|
146
|
+
table: Type[DeclarativeBaseT],
|
147
147
|
parent_column: str = "parent_id",
|
148
148
|
is_child: OptionalBoolean = None,
|
149
149
|
) -> Select[R]:
|
@@ -160,7 +160,7 @@ def filter_is_child(
|
|
160
160
|
def filter_is_leaf(
|
161
161
|
session: Session,
|
162
162
|
stmt: Select[R],
|
163
|
-
table: Type[
|
163
|
+
table: Type[DeclarativeBaseT],
|
164
164
|
id_column: str = "id",
|
165
165
|
parent_column: str = "parent_id",
|
166
166
|
is_leaf: OptionalBoolean = None,
|
@@ -181,7 +181,7 @@ def filter_is_leaf(
|
|
181
181
|
|
182
182
|
def search(
|
183
183
|
stmt: Select[R],
|
184
|
-
table: Type[
|
184
|
+
table: Type[DeclarativeBaseT],
|
185
185
|
search: OptionalString = None,
|
186
186
|
columns: OptionalListOfStrings = None,
|
187
187
|
) -> Select[R]:
|
@@ -215,7 +215,7 @@ def search(
|
|
215
215
|
|
216
216
|
def sort(
|
217
217
|
stmt: Select[R],
|
218
|
-
table: Type[
|
218
|
+
table: Type[DeclarativeBaseT],
|
219
219
|
sort_columns: Sequence[SortColumn],
|
220
220
|
) -> Select[R]:
|
221
221
|
for sort_column in sort_columns:
|
maleo/database/types.py
ADDED
@@ -1,21 +1,22 @@
|
|
1
1
|
maleo/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
maleo/database/dtos.py,sha256=DArPtSXzPJd896i-t4OmoqBP1mW-it8NVxvfWq7wq8Y,220
|
3
3
|
maleo/database/enums.py,sha256=tHJugOgGWEarwyHbUXmqK-AFXO-D-pmhIdXHkE81ik8,1691
|
4
|
-
maleo/database/handlers.py,sha256=
|
4
|
+
maleo/database/handlers.py,sha256=A8cY9yyqNhFO0L6kC1P3XdWO4xC9JXZQhK1JQs6AU2Q,4040
|
5
|
+
maleo/database/types.py,sha256=FFosx0E46pq7423Fc85P1uA8CRPaJsY0m88KG86oLjY,142
|
5
6
|
maleo/database/config/__init__.py,sha256=ygBWG1iq9tPCKo_mtcWgd5jcJ6gKhHmxXuZOmLuL2Hc,11102
|
6
7
|
maleo/database/config/additional.py,sha256=8uTEQDoKjAlXif-1njKuicIT07H_slTWr9pE0OENAU0,1098
|
7
8
|
maleo/database/config/connection.py,sha256=0Cg0XUxf20Q_RVqFmzOtBUXl9m7I-x9BEyEhZVoWEh4,22869
|
8
9
|
maleo/database/config/identifier.py,sha256=b1MjhoKl3h7xJe1eVIj1wjvYH9BrjHzKnjzdjaEaTeQ,626
|
9
10
|
maleo/database/config/pooling.py,sha256=4Q0rkM4FAt6xAbBG1PItHmMSzS7aCZNBgFPeaEjKwTo,11552
|
10
|
-
maleo/database/managers/__init__.py,sha256=
|
11
|
+
maleo/database/managers/__init__.py,sha256=9fITbrn9qjmzWp2oe5KmYVa2KZZxf-7INbiXd9ctxic,13333
|
11
12
|
maleo/database/managers/client.py,sha256=hdfPn8Ae8G78yZYDxI1FylcM-rPMIL8Ty4XmsASDrt0,3065
|
12
13
|
maleo/database/managers/engine.py,sha256=aF7JCjSYujodbn2QQrT_OeLX-WjUdIv5cBgWtvLgHI0,1725
|
13
14
|
maleo/database/managers/session.py,sha256=aKyuiHiA171Vptr92AA5U-mRwzwbKXb9RAZ9Wq5Wo4s,19557
|
14
15
|
maleo/database/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
16
|
maleo/database/orm/mixins.py,sha256=rW-FVOrRm_R8yJyrcwGoVIPPV1oAOhSVFmANHR7bowU,2372
|
16
|
-
maleo/database/orm/queries.py,sha256=
|
17
|
-
maleo_database-0.0.
|
18
|
-
maleo_database-0.0.
|
19
|
-
maleo_database-0.0.
|
20
|
-
maleo_database-0.0.
|
21
|
-
maleo_database-0.0.
|
17
|
+
maleo/database/orm/queries.py,sha256=GGt9Ca92IQwQ6YTjmx03xULQ7UPKkFckbHwZCzjdZDY,7456
|
18
|
+
maleo_database-0.0.24.dist-info/licenses/LICENSE,sha256=aftGsecnk7TWVX-7KW94FqK4Syy6YSZ8PZEF7EcIp3M,2621
|
19
|
+
maleo_database-0.0.24.dist-info/METADATA,sha256=tqqD2BBgJgJSWMuQhREnMtIa4kSyxBiDyDaGwwKiBJQ,3837
|
20
|
+
maleo_database-0.0.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
maleo_database-0.0.24.dist-info/top_level.txt,sha256=3Tpd1siVsfYoeI9FEOJNYnffx_shzZ3wsPpTvz5bljc,6
|
22
|
+
maleo_database-0.0.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|