maleo-database 0.0.14__tar.gz → 0.0.17__tar.gz
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-0.0.14 → maleo_database-0.0.17}/PKG-INFO +2 -2
- {maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/PKG-INFO +2 -2
- {maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/SOURCES.txt +1 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/requires.txt +1 -1
- {maleo_database-0.0.14 → maleo_database-0.0.17}/pyproject.toml +2 -2
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/config/__init__.py +105 -19
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/config/connection.py +15 -15
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/config/pooling.py +2 -2
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/enums.py +1 -1
- maleo_database-0.0.17/src/handlers.py +196 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/managers/__init__.py +36 -45
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/managers/client.py +3 -5
- {maleo_database-0.0.14 → maleo_database-0.0.17}/LICENSE +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/README.md +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/dependency_links.txt +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/top_level.txt +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/setup.cfg +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/__init__.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/config/additional.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/config/identifier.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/dtos.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/managers/engine.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/managers/session.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/__init__.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/base.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/__init__.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/mixins/__init__.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/mixins/identifier.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/mixins/status.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/mixins/timestamp.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/models/table.py +0 -0
- {maleo_database-0.0.14 → maleo_database-0.0.17}/src/orm/queries.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maleo-database
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.17
|
4
4
|
Summary: Database package for MaleoSuite
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
6
6
|
License: Proprietary
|
@@ -46,7 +46,7 @@ Requires-Dist: importlib_metadata>=8.7.0
|
|
46
46
|
Requires-Dist: maleo-constants>=0.0.6
|
47
47
|
Requires-Dist: maleo-dtos>=0.0.17
|
48
48
|
Requires-Dist: maleo-enums>=0.0.6
|
49
|
-
Requires-Dist: maleo-exceptions>=0.0.
|
49
|
+
Requires-Dist: maleo-exceptions>=0.0.21
|
50
50
|
Requires-Dist: maleo-logging>=0.0.7
|
51
51
|
Requires-Dist: maleo-mixins>=0.0.13
|
52
52
|
Requires-Dist: maleo-schemas>=0.0.20
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maleo-database
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.17
|
4
4
|
Summary: Database package for MaleoSuite
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
6
6
|
License: Proprietary
|
@@ -46,7 +46,7 @@ Requires-Dist: importlib_metadata>=8.7.0
|
|
46
46
|
Requires-Dist: maleo-constants>=0.0.6
|
47
47
|
Requires-Dist: maleo-dtos>=0.0.17
|
48
48
|
Requires-Dist: maleo-enums>=0.0.6
|
49
|
-
Requires-Dist: maleo-exceptions>=0.0.
|
49
|
+
Requires-Dist: maleo-exceptions>=0.0.21
|
50
50
|
Requires-Dist: maleo-logging>=0.0.7
|
51
51
|
Requires-Dist: maleo-mixins>=0.0.13
|
52
52
|
Requires-Dist: maleo-schemas>=0.0.20
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "maleo-database"
|
7
|
-
version = "0.0.
|
7
|
+
version = "0.0.17"
|
8
8
|
description = "Database package for MaleoSuite"
|
9
9
|
authors = [
|
10
10
|
{ name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
|
@@ -52,7 +52,7 @@ dependencies = [
|
|
52
52
|
"maleo-constants>=0.0.6",
|
53
53
|
"maleo-dtos>=0.0.17",
|
54
54
|
"maleo-enums>=0.0.6",
|
55
|
-
"maleo-exceptions>=0.0.
|
55
|
+
"maleo-exceptions>=0.0.21",
|
56
56
|
"maleo-logging>=0.0.7",
|
57
57
|
"maleo-mixins>=0.0.13",
|
58
58
|
"maleo-schemas>=0.0.20",
|
@@ -6,7 +6,7 @@ from redis.asyncio import Redis as AsyncRedis
|
|
6
6
|
from redis import Redis as SyncRedis
|
7
7
|
from sqlalchemy.engine import create_engine as create_sync_engine, Engine
|
8
8
|
from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine
|
9
|
-
from typing import Generic, Literal, TypeVar, Union, overload
|
9
|
+
from typing import Generic, Literal, Optional, TypeVar, Union, overload
|
10
10
|
from maleo.types.base.dict import StringToAnyDict
|
11
11
|
from ..enums import Connection
|
12
12
|
from .additional import AdditionalConfigT, RedisAdditionalConfig
|
@@ -16,7 +16,7 @@ from .connection import (
|
|
16
16
|
MySQLConnectionConfig,
|
17
17
|
SQLiteConnectionConfig,
|
18
18
|
SQLServerConnectionConfig,
|
19
|
-
|
19
|
+
MongoConnectionConfig,
|
20
20
|
RedisConnectionConfig,
|
21
21
|
ElasticsearchConnectionConfig,
|
22
22
|
)
|
@@ -27,7 +27,7 @@ from .pooling import (
|
|
27
27
|
MySQLPoolingConfig,
|
28
28
|
SQLitePoolingConfig,
|
29
29
|
SQLServerPoolingConfig,
|
30
|
-
|
30
|
+
MongoPoolingConfig,
|
31
31
|
RedisPoolingConfig,
|
32
32
|
ElasticsearchPoolingConfig,
|
33
33
|
)
|
@@ -204,10 +204,10 @@ class ElasticsearchConfig(
|
|
204
204
|
return Elasticsearch(hosts, **self.client_kwargs)
|
205
205
|
|
206
206
|
|
207
|
-
class
|
207
|
+
class MongoConfig(
|
208
208
|
BaseConfig[
|
209
|
-
|
210
|
-
|
209
|
+
MongoConnectionConfig,
|
210
|
+
MongoPoolingConfig,
|
211
211
|
None,
|
212
212
|
]
|
213
213
|
):
|
@@ -261,30 +261,116 @@ class RedisConfig(
|
|
261
261
|
NoSQLConfigT = TypeVar(
|
262
262
|
"NoSQLConfigT",
|
263
263
|
ElasticsearchConfig,
|
264
|
-
|
264
|
+
MongoConfig,
|
265
265
|
RedisConfig,
|
266
266
|
)
|
267
267
|
|
268
268
|
|
269
|
-
|
270
|
-
"
|
271
|
-
|
269
|
+
ConfigT = TypeVar(
|
270
|
+
"ConfigT",
|
271
|
+
ElasticsearchConfig,
|
272
|
+
MongoConfig,
|
273
|
+
RedisConfig,
|
272
274
|
MySQLConfig,
|
275
|
+
PostgreSQLConfig,
|
273
276
|
SQLiteConfig,
|
274
277
|
SQLServerConfig,
|
275
|
-
MongoDBConfig,
|
276
|
-
RedisConfig,
|
277
|
-
ElasticsearchConfig,
|
278
278
|
)
|
279
279
|
|
280
280
|
|
281
|
-
|
282
|
-
|
283
|
-
|
281
|
+
class ElasticsearchConfigs(BaseModel):
|
282
|
+
primary: ElasticsearchConfig = Field(
|
283
|
+
..., description="Primary Elasticsearch config"
|
284
|
+
)
|
285
|
+
|
286
|
+
|
287
|
+
ElasticsearchConfigsT = TypeVar(
|
288
|
+
"ElasticsearchConfigsT", bound=Optional[ElasticsearchConfigs]
|
289
|
+
)
|
290
|
+
|
291
|
+
|
292
|
+
class MongoConfigs(BaseModel):
|
293
|
+
primary: MongoConfig = Field(..., description="Primary Mongo config")
|
294
|
+
|
295
|
+
|
296
|
+
MongoConfigsT = TypeVar("MongoConfigsT", bound=Optional[MongoConfigs])
|
297
|
+
|
298
|
+
|
299
|
+
class RedisConfigs(BaseModel):
|
300
|
+
primary: RedisConfig = Field(..., description="Primary Redis config")
|
301
|
+
|
302
|
+
|
303
|
+
RedisConfigsT = TypeVar("RedisConfigsT", bound=Optional[RedisConfigs])
|
304
|
+
|
305
|
+
|
306
|
+
class NoSQLConfigs(
|
307
|
+
BaseModel, Generic[ElasticsearchConfigsT, MongoConfigsT, RedisConfigsT]
|
308
|
+
):
|
309
|
+
elasticsearch: ElasticsearchConfigsT = Field(
|
310
|
+
..., description="Elasticsearch configs"
|
311
|
+
)
|
312
|
+
mongo: MongoConfigsT = Field(..., description="Mongo configs")
|
313
|
+
redis: RedisConfigsT = Field(..., description="Redis configs")
|
314
|
+
|
315
|
+
|
316
|
+
NoSQLConfigsT = TypeVar("NoSQLConfigsT", bound=Optional[NoSQLConfigs])
|
284
317
|
|
285
318
|
|
286
|
-
|
319
|
+
class MySQLConfigs(BaseModel):
|
320
|
+
primary: MySQLConfig = Field(..., description="Primary MySQL config")
|
321
|
+
|
322
|
+
|
323
|
+
MySQLConfigsT = TypeVar("MySQLConfigsT", bound=Optional[MySQLConfigs])
|
324
|
+
|
325
|
+
|
326
|
+
class PostgreSQLConfigs(BaseModel):
|
327
|
+
primary: PostgreSQLConfig = Field(..., description="Primary PostgreSQL config")
|
328
|
+
|
329
|
+
|
330
|
+
PostgreSQLConfigsT = TypeVar("PostgreSQLConfigsT", bound=Optional[PostgreSQLConfigs])
|
331
|
+
|
332
|
+
|
333
|
+
class SQLiteConfigs(BaseModel):
|
334
|
+
primary: SQLiteConfig = Field(..., description="Primary SQLite config")
|
335
|
+
|
336
|
+
|
337
|
+
SQLiteConfigsT = TypeVar("SQLiteConfigsT", bound=Optional[SQLiteConfigs])
|
338
|
+
|
339
|
+
|
340
|
+
class SQLServerConfigs(BaseModel):
|
341
|
+
primary: SQLServerConfig = Field(..., description="Primary SQLServer config")
|
342
|
+
|
343
|
+
|
344
|
+
SQLServerConfigsT = TypeVar("SQLServerConfigsT", bound=Optional[SQLServerConfigs])
|
345
|
+
|
346
|
+
|
347
|
+
class SQLConfigs(
|
348
|
+
BaseModel,
|
349
|
+
Generic[
|
350
|
+
MySQLConfigsT,
|
351
|
+
PostgreSQLConfigsT,
|
352
|
+
SQLiteConfigsT,
|
353
|
+
SQLServerConfigsT,
|
354
|
+
],
|
355
|
+
):
|
356
|
+
mysql: MySQLConfigsT = Field(..., description="MySQL configs")
|
357
|
+
postgresql: PostgreSQLConfigsT = Field(..., description="PostgreSQL configs")
|
358
|
+
sqlite: SQLiteConfigsT = Field(..., description="SQLite configs")
|
359
|
+
sqlserver: SQLServerConfigsT = Field(..., description="SQLServer configs")
|
360
|
+
|
361
|
+
|
362
|
+
SQLConfigsT = TypeVar("SQLConfigsT", bound=Optional[SQLConfigs])
|
363
|
+
|
364
|
+
|
365
|
+
class Configs(
|
366
|
+
BaseModel,
|
367
|
+
Generic[
|
368
|
+
NoSQLConfigsT,
|
369
|
+
SQLConfigsT,
|
370
|
+
],
|
371
|
+
):
|
372
|
+
nosql: NoSQLConfigsT = Field(..., description="NoSQL configs")
|
373
|
+
sql: SQLConfigsT = Field(..., description="SQL configs")
|
287
374
|
|
288
375
|
|
289
|
-
|
290
|
-
database: ConfigT = Field(..., description="Databases config")
|
376
|
+
ConfigsT = TypeVar("ConfigsT", bound=Optional[Configs])
|
@@ -14,7 +14,7 @@ from ..enums import (
|
|
14
14
|
Driver,
|
15
15
|
PostgreSQLSSLMode,
|
16
16
|
MySQLCharset,
|
17
|
-
|
17
|
+
MongoReadPreference,
|
18
18
|
ElasticsearchScheme,
|
19
19
|
)
|
20
20
|
|
@@ -41,7 +41,7 @@ class BaseConnectionConfig(
|
|
41
41
|
|
42
42
|
# Optional fields for different database types
|
43
43
|
auth_source: OptionalString = Field(
|
44
|
-
None, description="Authentication database (
|
44
|
+
None, description="Authentication database (Mongo)"
|
45
45
|
)
|
46
46
|
ssl: OptionalBoolean = Field(None, description="Enable SSL connection")
|
47
47
|
options: OptionalStringToAnyDict = Field(
|
@@ -70,7 +70,7 @@ class BaseConnectionConfig(
|
|
70
70
|
raise ValueError("Redis requires host")
|
71
71
|
elif self.driver is Driver.MONGODB:
|
72
72
|
if not self.host:
|
73
|
-
raise ValueError("
|
73
|
+
raise ValueError("Mongo requires host")
|
74
74
|
|
75
75
|
return self
|
76
76
|
|
@@ -141,7 +141,7 @@ class BaseConnectionConfig(
|
|
141
141
|
raise NotImplementedError()
|
142
142
|
|
143
143
|
def _make_mongodb_url(self) -> str:
|
144
|
-
"""
|
144
|
+
"""Mongo URL format - Mongo driver handles async/sync internally."""
|
145
145
|
raise NotImplementedError()
|
146
146
|
|
147
147
|
def _make_redis_url(self) -> str:
|
@@ -409,21 +409,21 @@ class SQLServerConnectionConfig(
|
|
409
409
|
return self.model_dump(include={"echo"}, exclude_none=True)
|
410
410
|
|
411
411
|
|
412
|
-
class
|
412
|
+
class MongoConnectionConfig(
|
413
413
|
BaseConnectionConfig[
|
414
414
|
Literal[Driver.MONGODB], OptionalString, OptionalString, str, int, str
|
415
415
|
]
|
416
416
|
):
|
417
417
|
driver: Literal[Driver.MONGODB] = Driver.MONGODB
|
418
|
-
port: int = Field(27017, description="
|
419
|
-
username: OptionalString = Field(None, description="
|
420
|
-
password: OptionalString = Field(None, description="
|
418
|
+
port: int = Field(27017, description="Mongo port")
|
419
|
+
username: OptionalString = Field(None, description="Mongo username")
|
420
|
+
password: OptionalString = Field(None, description="Mongo password")
|
421
421
|
|
422
|
-
#
|
422
|
+
# Mongo-specific options
|
423
423
|
auth_source: OptionalString = Field("admin", description="Authentication database")
|
424
424
|
replica_set: OptionalString = Field(None, description="Replica set name")
|
425
|
-
read_preference: Optional[
|
426
|
-
|
425
|
+
read_preference: Optional[MongoReadPreference] = Field(
|
426
|
+
MongoReadPreference.PRIMARY, description="Read preference"
|
427
427
|
)
|
428
428
|
|
429
429
|
@model_validator(mode="after")
|
@@ -436,8 +436,8 @@ class MongoDBConnectionConfig(
|
|
436
436
|
return self
|
437
437
|
|
438
438
|
def _make_mongodb_url(self) -> str:
|
439
|
-
"""
|
440
|
-
#
|
439
|
+
"""Mongo URL format - Mongo driver handles async/sync internally."""
|
440
|
+
# Mongo uses the same URL format for both async and sync
|
441
441
|
# The async/sync behavior is determined by the client library used
|
442
442
|
|
443
443
|
auth_part = ""
|
@@ -448,7 +448,7 @@ class MongoDBConnectionConfig(
|
|
448
448
|
|
449
449
|
base_url = f"mongodb://{auth_part}{self.host}:{self.port}/{self.database}"
|
450
450
|
|
451
|
-
# Add
|
451
|
+
# Add Mongo-specific options
|
452
452
|
mongo_options = {
|
453
453
|
"authSource": self.auth_source,
|
454
454
|
"replicaSet": self.replica_set,
|
@@ -547,7 +547,7 @@ def create_connection_config(driver: Driver, **kwargs) -> BaseConnectionConfig:
|
|
547
547
|
Driver.POSTGRESQL: PostgreSQLConnectionConfig,
|
548
548
|
Driver.MYSQL: MySQLConnectionConfig,
|
549
549
|
Driver.SQLITE: SQLiteConnectionConfig,
|
550
|
-
Driver.MONGODB:
|
550
|
+
Driver.MONGODB: MongoConnectionConfig,
|
551
551
|
Driver.REDIS: RedisConnectionConfig,
|
552
552
|
Driver.MSSQL: SQLServerConnectionConfig,
|
553
553
|
Driver.ELASTICSEARCH: ElasticsearchConnectionConfig,
|
@@ -258,8 +258,8 @@ class ElasticsearchPoolingConfig(BasePoolingConfig):
|
|
258
258
|
return self.model_dump(exclude=self.client_kwargs_exclusions, exclude_none=True)
|
259
259
|
|
260
260
|
|
261
|
-
class
|
262
|
-
"""
|
261
|
+
class MongoPoolingConfig(BasePoolingConfig):
|
262
|
+
"""Mongo-specific pooling configuration."""
|
263
263
|
|
264
264
|
model_config = ConfigDict(alias_generator=to_camel)
|
265
265
|
|
@@ -0,0 +1,196 @@
|
|
1
|
+
from pydantic import BaseModel, ConfigDict, Field
|
2
|
+
from sqlalchemy import MetaData
|
3
|
+
from typing import Generic, Optional, TypeVar
|
4
|
+
from maleo.dtos.contexts.service import ServiceContext
|
5
|
+
from maleo.logging.logger import Database
|
6
|
+
from .config import (
|
7
|
+
ElasticsearchConfig,
|
8
|
+
MongoConfig,
|
9
|
+
RedisConfig,
|
10
|
+
MySQLConfig,
|
11
|
+
PostgreSQLConfig,
|
12
|
+
SQLiteConfig,
|
13
|
+
SQLServerConfig,
|
14
|
+
ConfigT,
|
15
|
+
)
|
16
|
+
from .managers import (
|
17
|
+
ElasticsearchManager,
|
18
|
+
MongoManager,
|
19
|
+
RedisManager,
|
20
|
+
MySQLManager,
|
21
|
+
PostgreSQLManager,
|
22
|
+
SQLiteManager,
|
23
|
+
SQLServerManager,
|
24
|
+
ManagerT,
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
class Handler(
|
29
|
+
BaseModel,
|
30
|
+
Generic[
|
31
|
+
ConfigT,
|
32
|
+
ManagerT,
|
33
|
+
],
|
34
|
+
):
|
35
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
36
|
+
|
37
|
+
config: ConfigT = Field(..., description="Config")
|
38
|
+
manager: ManagerT = Field(..., description="Manager")
|
39
|
+
|
40
|
+
|
41
|
+
HandlerT = TypeVar("HandlerT", bound=Handler)
|
42
|
+
|
43
|
+
|
44
|
+
class ElasticsearchHandler(Handler[ElasticsearchConfig, ElasticsearchManager]):
|
45
|
+
@classmethod
|
46
|
+
def new(
|
47
|
+
cls,
|
48
|
+
config: ElasticsearchConfig,
|
49
|
+
logger: Database,
|
50
|
+
service_context: Optional[ServiceContext] = None,
|
51
|
+
) -> "ElasticsearchHandler":
|
52
|
+
manager = ElasticsearchManager(
|
53
|
+
config=config, logger=logger, service_context=service_context
|
54
|
+
)
|
55
|
+
return cls(config=config, manager=manager)
|
56
|
+
|
57
|
+
|
58
|
+
class MongoHandler(Handler[MongoConfig, MongoManager]):
|
59
|
+
pass
|
60
|
+
|
61
|
+
|
62
|
+
class RedisHandler(Handler[RedisConfig, RedisManager]):
|
63
|
+
pass
|
64
|
+
|
65
|
+
|
66
|
+
class MySQLHandler(Handler[MySQLConfig, MySQLManager]):
|
67
|
+
pass
|
68
|
+
|
69
|
+
|
70
|
+
class PostgreSQLHandler(Handler[PostgreSQLConfig, PostgreSQLManager]):
|
71
|
+
@classmethod
|
72
|
+
def new(
|
73
|
+
cls,
|
74
|
+
config: PostgreSQLConfig,
|
75
|
+
logger: Database,
|
76
|
+
metadata: MetaData,
|
77
|
+
service_context: Optional[ServiceContext] = None,
|
78
|
+
) -> "PostgreSQLHandler":
|
79
|
+
manager = PostgreSQLManager(
|
80
|
+
config=config,
|
81
|
+
logger=logger,
|
82
|
+
metadata=metadata,
|
83
|
+
service_context=service_context,
|
84
|
+
)
|
85
|
+
return cls(config=config, manager=manager)
|
86
|
+
|
87
|
+
|
88
|
+
class SQLiteHandler(Handler[SQLiteConfig, SQLiteManager]):
|
89
|
+
pass
|
90
|
+
|
91
|
+
|
92
|
+
class SQLServerHandler(Handler[SQLServerConfig, SQLServerManager]):
|
93
|
+
pass
|
94
|
+
|
95
|
+
|
96
|
+
class BaseHandlers(BaseModel, Generic[HandlerT]):
|
97
|
+
primary: HandlerT = Field(..., description="Primary handler")
|
98
|
+
|
99
|
+
|
100
|
+
BaseHandlersT = TypeVar("BaseHandlersT", bound=Optional[BaseHandlers])
|
101
|
+
|
102
|
+
|
103
|
+
class ElasticsearchHandlers(BaseHandlers[ElasticsearchHandler]):
|
104
|
+
pass
|
105
|
+
|
106
|
+
|
107
|
+
ElasticsearchHandlersT = TypeVar(
|
108
|
+
"ElasticsearchHandlersT", bound=Optional[ElasticsearchHandlers]
|
109
|
+
)
|
110
|
+
|
111
|
+
|
112
|
+
class MongoHandlers(BaseHandlers[MongoHandler]):
|
113
|
+
pass
|
114
|
+
|
115
|
+
|
116
|
+
MongoHandlersT = TypeVar("MongoHandlersT", bound=Optional[MongoHandlers])
|
117
|
+
|
118
|
+
|
119
|
+
class RedisHandlers(BaseHandlers[RedisHandler]):
|
120
|
+
pass
|
121
|
+
|
122
|
+
|
123
|
+
RedisHandlersT = TypeVar("RedisHandlersT", bound=Optional[RedisHandlers])
|
124
|
+
|
125
|
+
|
126
|
+
class NoSQLHandlers(
|
127
|
+
BaseModel, Generic[ElasticsearchHandlersT, MongoHandlersT, RedisHandlersT]
|
128
|
+
):
|
129
|
+
elasticsearch: ElasticsearchHandlersT = Field(
|
130
|
+
..., description="Elasticsearch handlers"
|
131
|
+
)
|
132
|
+
mongo: MongoHandlersT = Field(..., description="Mongo handlers")
|
133
|
+
redis: RedisHandlersT = Field(..., description="Redis handlers")
|
134
|
+
|
135
|
+
|
136
|
+
NoSQLHandlersT = TypeVar("NoSQLHandlersT", bound=Optional[NoSQLHandlers])
|
137
|
+
|
138
|
+
|
139
|
+
class MySQLHandlers(BaseHandlers[MySQLHandler]):
|
140
|
+
pass
|
141
|
+
|
142
|
+
|
143
|
+
MySQLHandlersT = TypeVar("MySQLHandlersT", bound=Optional[MySQLHandlers])
|
144
|
+
|
145
|
+
|
146
|
+
class PostgreSQLHandlers(BaseHandlers[PostgreSQLHandler]):
|
147
|
+
pass
|
148
|
+
|
149
|
+
|
150
|
+
PostgreSQLHandlersT = TypeVar("PostgreSQLHandlersT", bound=Optional[PostgreSQLHandlers])
|
151
|
+
|
152
|
+
|
153
|
+
class SQLiteHandlers(BaseHandlers[SQLiteHandler]):
|
154
|
+
pass
|
155
|
+
|
156
|
+
|
157
|
+
SQLiteHandlersT = TypeVar("SQLiteHandlersT", bound=Optional[SQLiteHandlers])
|
158
|
+
|
159
|
+
|
160
|
+
class SQLServerHandlers(BaseHandlers[SQLServerHandler]):
|
161
|
+
pass
|
162
|
+
|
163
|
+
|
164
|
+
SQLServerHandlersT = TypeVar("SQLServerHandlersT", bound=Optional[SQLServerHandlers])
|
165
|
+
|
166
|
+
|
167
|
+
class SQLHandlers(
|
168
|
+
BaseModel,
|
169
|
+
Generic[
|
170
|
+
MySQLHandlersT,
|
171
|
+
PostgreSQLHandlersT,
|
172
|
+
SQLiteHandlersT,
|
173
|
+
SQLServerHandlersT,
|
174
|
+
],
|
175
|
+
):
|
176
|
+
mysql: MySQLHandlersT = Field(..., description="MySQL handlers")
|
177
|
+
postgresql: PostgreSQLHandlersT = Field(..., description="PostgreSQL handlers")
|
178
|
+
sqlite: SQLiteHandlersT = Field(..., description="SQLite handlers")
|
179
|
+
sqlserver: SQLServerHandlersT = Field(..., description="SQLServer handlers")
|
180
|
+
|
181
|
+
|
182
|
+
SQLHandlersT = TypeVar("SQLHandlersT", bound=Optional[SQLHandlers])
|
183
|
+
|
184
|
+
|
185
|
+
class Handlers(
|
186
|
+
BaseModel,
|
187
|
+
Generic[
|
188
|
+
NoSQLHandlersT,
|
189
|
+
SQLHandlersT,
|
190
|
+
],
|
191
|
+
):
|
192
|
+
nosql: NoSQLHandlersT = Field(..., description="NoSQL handlers")
|
193
|
+
sql: NoSQLHandlersT = Field(..., description="SQL handlers")
|
194
|
+
|
195
|
+
|
196
|
+
HandlersT = TypeVar("HandlersT", bound=Optional[Handlers])
|
@@ -37,7 +37,7 @@ from ..config import (
|
|
37
37
|
SQLServerConfig,
|
38
38
|
SQLConfigT,
|
39
39
|
ElasticsearchConfig,
|
40
|
-
|
40
|
+
MongoConfig,
|
41
41
|
RedisConfig,
|
42
42
|
NoSQLConfigT,
|
43
43
|
ConfigT,
|
@@ -52,7 +52,7 @@ from .engine import EngineManager
|
|
52
52
|
from .session import SessionManager
|
53
53
|
|
54
54
|
|
55
|
-
class
|
55
|
+
class Manager(ABC, Generic[ConfigT]):
|
56
56
|
def __init__(
|
57
57
|
self,
|
58
58
|
config: ConfigT,
|
@@ -96,12 +96,12 @@ class DatabaseManager(ABC, Generic[ConfigT]):
|
|
96
96
|
pass
|
97
97
|
|
98
98
|
|
99
|
-
class
|
99
|
+
class SQLManager(Manager[SQLConfigT], Generic[SQLConfigT]):
|
100
100
|
def __init__(
|
101
101
|
self,
|
102
102
|
config: SQLConfigT,
|
103
|
-
metadata: MetaData,
|
104
103
|
logger: Database,
|
104
|
+
metadata: MetaData,
|
105
105
|
service_context: Optional[ServiceContext] = None,
|
106
106
|
) -> None:
|
107
107
|
super().__init__(config, logger, service_context)
|
@@ -124,7 +124,7 @@ class SQLDatabaseManager(DatabaseManager[SQLConfigT], Generic[SQLConfigT]):
|
|
124
124
|
def session(self) -> SessionManager:
|
125
125
|
return self._session_manager
|
126
126
|
|
127
|
-
async def
|
127
|
+
async def async_check_connection(
|
128
128
|
self,
|
129
129
|
operation_id: OptionalUUID = None,
|
130
130
|
request_context: Optional[RequestContext] = None,
|
@@ -251,33 +251,33 @@ class SQLDatabaseManager(DatabaseManager[SQLConfigT], Generic[SQLConfigT]):
|
|
251
251
|
await self._engine_manager.dispose()
|
252
252
|
|
253
253
|
|
254
|
-
class
|
254
|
+
class MySQLManager(SQLManager[MySQLConfig]):
|
255
255
|
pass
|
256
256
|
|
257
257
|
|
258
|
-
class
|
258
|
+
class PostgreSQLManager(SQLManager[PostgreSQLConfig]):
|
259
259
|
pass
|
260
260
|
|
261
261
|
|
262
|
-
class
|
262
|
+
class SQLiteManager(SQLManager[SQLiteConfig]):
|
263
263
|
pass
|
264
264
|
|
265
265
|
|
266
|
-
class
|
266
|
+
class SQLServerManager(SQLManager[SQLServerConfig]):
|
267
267
|
pass
|
268
268
|
|
269
269
|
|
270
|
-
|
271
|
-
"
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
270
|
+
SQLManagerT = TypeVar(
|
271
|
+
"SQLManagerT",
|
272
|
+
MySQLManager,
|
273
|
+
PostgreSQLManager,
|
274
|
+
SQLiteManager,
|
275
|
+
SQLServerManager,
|
276
276
|
)
|
277
277
|
|
278
278
|
|
279
|
-
class
|
280
|
-
|
279
|
+
class NoSQLManager(
|
280
|
+
Manager[NoSQLConfigT],
|
281
281
|
Generic[
|
282
282
|
NoSQLConfigT,
|
283
283
|
AsyncClientT,
|
@@ -287,12 +287,10 @@ class NoSQLDatabaseManager(
|
|
287
287
|
def __init__(
|
288
288
|
self,
|
289
289
|
config: NoSQLConfigT,
|
290
|
-
metadata: MetaData,
|
291
290
|
logger: Database,
|
292
291
|
service_context: Optional[ServiceContext] = None,
|
293
292
|
) -> None:
|
294
293
|
super().__init__(config, logger, service_context)
|
295
|
-
self._metadata = metadata
|
296
294
|
self._operation_context.target.details = self._config.model_dump()
|
297
295
|
self._client_manager = ClientManager[
|
298
296
|
NoSQLConfigT,
|
@@ -308,7 +306,7 @@ class NoSQLDatabaseManager(
|
|
308
306
|
]:
|
309
307
|
return self._client_manager
|
310
308
|
|
311
|
-
async def
|
309
|
+
async def async_check_connection(
|
312
310
|
self,
|
313
311
|
operation_id: OptionalUUID = None,
|
314
312
|
request_context: Optional[RequestContext] = None,
|
@@ -360,42 +358,35 @@ class NoSQLDatabaseManager(
|
|
360
358
|
await self._client_manager.dispose()
|
361
359
|
|
362
360
|
|
363
|
-
class
|
364
|
-
|
361
|
+
class ElasticsearchManager(
|
362
|
+
NoSQLManager[ElasticsearchConfig, AsyncElasticsearch, Elasticsearch]
|
365
363
|
):
|
366
364
|
pass
|
367
365
|
|
368
366
|
|
369
|
-
class
|
370
|
-
NoSQLDatabaseManager[MongoDBConfig, AsyncIOMotorClient, MongoClient]
|
371
|
-
):
|
367
|
+
class MongoManager(NoSQLManager[MongoConfig, AsyncIOMotorClient, MongoClient]):
|
372
368
|
pass
|
373
369
|
|
374
370
|
|
375
|
-
class
|
371
|
+
class RedisManager(NoSQLManager[RedisConfig, AsyncRedis, SyncRedis]):
|
376
372
|
pass
|
377
373
|
|
378
374
|
|
379
|
-
|
380
|
-
"
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
)
|
385
|
-
|
386
|
-
|
387
|
-
GenericDatabaseManagerT = TypeVar(
|
388
|
-
"GenericDatabaseManagerT", SQLDatabaseManager, NoSQLDatabaseManager
|
375
|
+
NoSQLManagerT = TypeVar(
|
376
|
+
"NoSQLManagerT",
|
377
|
+
ElasticsearchManager,
|
378
|
+
MongoManager,
|
379
|
+
RedisManager,
|
389
380
|
)
|
390
381
|
|
391
382
|
|
392
|
-
|
393
|
-
"
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
383
|
+
ManagerT = TypeVar(
|
384
|
+
"ManagerT",
|
385
|
+
ElasticsearchManager,
|
386
|
+
MongoManager,
|
387
|
+
RedisManager,
|
388
|
+
MySQLManager,
|
389
|
+
PostgreSQLManager,
|
390
|
+
SQLiteManager,
|
391
|
+
SQLServerManager,
|
401
392
|
)
|
@@ -7,7 +7,7 @@ from typing import Generic, Literal, Optional, Tuple, TypeVar, Union, overload
|
|
7
7
|
from maleo.types.base.string import ListOfStrings
|
8
8
|
from ..config import (
|
9
9
|
ElasticsearchConfig,
|
10
|
-
|
10
|
+
MongoConfig,
|
11
11
|
RedisConfig,
|
12
12
|
NoSQLConfigT,
|
13
13
|
)
|
@@ -65,9 +65,7 @@ class ElasticsearchClientManager(
|
|
65
65
|
pass
|
66
66
|
|
67
67
|
|
68
|
-
class
|
69
|
-
ClientManager[MongoDBConfig, AsyncIOMotorClient, MongoClient]
|
70
|
-
):
|
68
|
+
class MongoClientManager(ClientManager[MongoConfig, AsyncIOMotorClient, MongoClient]):
|
71
69
|
pass
|
72
70
|
|
73
71
|
|
@@ -98,6 +96,6 @@ class RedisClientManager(ClientManager[RedisConfig, AsyncRedis, SyncRedis]):
|
|
98
96
|
ClientManagerT = TypeVar(
|
99
97
|
"ClientManagerT",
|
100
98
|
ElasticsearchClientManager,
|
101
|
-
|
99
|
+
MongoClientManager,
|
102
100
|
RedisClientManager,
|
103
101
|
)
|
File without changes
|
File without changes
|
{maleo_database-0.0.14 → maleo_database-0.0.17}/maleo_database.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|