maleo-database 0.0.4__tar.gz → 0.0.6__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.
Files changed (43) hide show
  1. {maleo_database-0.0.4 → maleo_database-0.0.6}/PKG-INFO +23 -8
  2. {maleo_database-0.0.4 → maleo_database-0.0.6}/maleo_database.egg-info/PKG-INFO +23 -8
  3. {maleo_database-0.0.4 → maleo_database-0.0.6}/maleo_database.egg-info/SOURCES.txt +3 -9
  4. {maleo_database-0.0.4 → maleo_database-0.0.6}/maleo_database.egg-info/requires.txt +22 -7
  5. {maleo_database-0.0.4 → maleo_database-0.0.6}/pyproject.toml +23 -14
  6. maleo_database-0.0.6/src/config/__init__.py +278 -0
  7. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/config/connection.py +46 -30
  8. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/config/pooling.py +171 -83
  9. maleo_database-0.0.6/src/dtos.py +6 -0
  10. maleo_database-0.0.6/src/managers/__init__.py +427 -0
  11. maleo_database-0.0.6/src/managers/client.py +82 -0
  12. maleo_database-0.0.6/src/managers/engine.py +64 -0
  13. maleo_database-0.0.6/src/managers/session.py +532 -0
  14. maleo_database-0.0.4/src/config/__init__.py +0 -105
  15. maleo_database-0.0.4/src/managers/clients/elasticsearch.py +0 -66
  16. maleo_database-0.0.4/src/managers/clients/mongodb.py +0 -53
  17. maleo_database-0.0.4/src/managers/clients/redis.py +0 -57
  18. maleo_database-0.0.4/src/managers/engines/mysql.py +0 -56
  19. maleo_database-0.0.4/src/managers/engines/postgresql.py +0 -58
  20. maleo_database-0.0.4/src/managers/engines/sqlite.py +0 -55
  21. maleo_database-0.0.4/src/managers/engines/sqlserver.py +0 -63
  22. maleo_database-0.0.4/src/managers/session.py +0 -256
  23. maleo_database-0.0.4/src/orm/__init__.py +0 -0
  24. maleo_database-0.0.4/src/orm/models/__init__.py +0 -0
  25. maleo_database-0.0.4/src/orm/models/mixins/__init__.py +0 -0
  26. {maleo_database-0.0.4 → maleo_database-0.0.6}/LICENSE +0 -0
  27. {maleo_database-0.0.4 → maleo_database-0.0.6}/README.md +0 -0
  28. {maleo_database-0.0.4 → maleo_database-0.0.6}/maleo_database.egg-info/dependency_links.txt +0 -0
  29. {maleo_database-0.0.4 → maleo_database-0.0.6}/maleo_database.egg-info/top_level.txt +0 -0
  30. {maleo_database-0.0.4 → maleo_database-0.0.6}/setup.cfg +0 -0
  31. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/__init__.py +0 -0
  32. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/config/additional.py +0 -0
  33. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/config/identifier.py +0 -0
  34. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/enums.py +0 -0
  35. {maleo_database-0.0.4/src/managers → maleo_database-0.0.6/src/orm}/__init__.py +0 -0
  36. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/orm/base.py +0 -0
  37. {maleo_database-0.0.4/src/managers/clients → maleo_database-0.0.6/src/orm/models}/__init__.py +0 -0
  38. {maleo_database-0.0.4/src/managers/engines → maleo_database-0.0.6/src/orm/models/mixins}/__init__.py +0 -0
  39. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/orm/models/mixins/identifier.py +0 -0
  40. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/orm/models/mixins/status.py +0 -0
  41. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/orm/models/mixins/timestamp.py +0 -0
  42. {maleo_database-0.0.4 → maleo_database-0.0.6}/src/orm/models/table.py +0 -0
  43. {maleo_database-0.0.4 → maleo_database-0.0.6}/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.4
3
+ Version: 0.0.6
4
4
  Summary: Database package for MaleoSuite
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -18,7 +18,7 @@ Requires-Dist: cffi>=1.17.1
18
18
  Requires-Dist: cfgv>=3.4.0
19
19
  Requires-Dist: charset-normalizer>=3.4.3
20
20
  Requires-Dist: click>=8.2.1
21
- Requires-Dist: cryptography>=45.0.6
21
+ Requires-Dist: cryptography>=45.0.7
22
22
  Requires-Dist: distlib>=0.4.0
23
23
  Requires-Dist: dnspython>=2.7.0
24
24
  Requires-Dist: elastic-transport>=9.1.0
@@ -31,25 +31,35 @@ Requires-Dist: google-cloud-appengine-logging>=1.6.2
31
31
  Requires-Dist: google-cloud-audit-log>=0.3.2
32
32
  Requires-Dist: google-cloud-core>=2.4.3
33
33
  Requires-Dist: google-cloud-logging>=3.12.1
34
+ Requires-Dist: google-cloud-pubsub>=2.31.1
34
35
  Requires-Dist: googleapis-common-protos>=1.70.0
35
36
  Requires-Dist: greenlet>=3.2.4
36
37
  Requires-Dist: grpc-google-iam-v1>=0.14.2
37
38
  Requires-Dist: grpcio>=1.74.0
38
39
  Requires-Dist: grpcio-status>=1.74.0
40
+ Requires-Dist: h11>=0.16.0
41
+ Requires-Dist: httpcore>=1.0.9
42
+ Requires-Dist: httpx>=0.28.1
39
43
  Requires-Dist: identify>=2.6.13
40
44
  Requires-Dist: idna>=3.10
41
45
  Requires-Dist: importlib_metadata>=8.7.0
42
- Requires-Dist: maleo-constants>=0.0.2
43
- Requires-Dist: maleo-enums>=0.0.3
44
- Requires-Dist: maleo-logging>=0.0.2
45
- Requires-Dist: maleo-mixins>=0.0.6
46
+ Requires-Dist: maleo-constants>=0.0.6
47
+ Requires-Dist: maleo-dtos>=0.0.11
48
+ Requires-Dist: maleo-enums>=0.0.6
49
+ Requires-Dist: maleo-exceptions>=0.0.12
50
+ Requires-Dist: maleo-logging>=0.0.6
51
+ Requires-Dist: maleo-mixins>=0.0.12
52
+ Requires-Dist: maleo-schemas>=0.0.14
46
53
  Requires-Dist: maleo-types-base>=0.0.2
47
- Requires-Dist: maleo-types-enums>=0.0.2
48
- Requires-Dist: maleo-utils>=0.0.3
54
+ Requires-Dist: maleo-types-controllers>=0.0.1
55
+ Requires-Dist: maleo-types-enums>=0.0.4
56
+ Requires-Dist: maleo-utils>=0.0.4
49
57
  Requires-Dist: motor>=3.7.1
50
58
  Requires-Dist: mypy_extensions>=1.1.0
51
59
  Requires-Dist: nodeenv>=1.9.1
52
60
  Requires-Dist: opentelemetry-api>=1.36.0
61
+ Requires-Dist: opentelemetry-sdk>=1.36.0
62
+ Requires-Dist: opentelemetry-semantic-conventions>=0.57b0
53
63
  Requires-Dist: packaging>=25.0
54
64
  Requires-Dist: pathspec>=0.12.1
55
65
  Requires-Dist: platformdirs>=4.4.0
@@ -61,9 +71,11 @@ Requires-Dist: pyasn1_modules>=0.4.2
61
71
  Requires-Dist: pycparser>=2.22
62
72
  Requires-Dist: pycryptodome>=3.23.0
63
73
  Requires-Dist: pydantic>=2.11.7
74
+ Requires-Dist: pydantic-settings>=2.10.1
64
75
  Requires-Dist: pydantic_core>=2.33.2
65
76
  Requires-Dist: pymongo>=4.14.1
66
77
  Requires-Dist: python-dateutil>=2.9.0.post0
78
+ Requires-Dist: python-dotenv>=1.1.1
67
79
  Requires-Dist: PyYAML>=6.0.2
68
80
  Requires-Dist: redis>=6.4.0
69
81
  Requires-Dist: requests>=2.32.5
@@ -74,7 +86,10 @@ Requires-Dist: SQLAlchemy>=2.0.43
74
86
  Requires-Dist: starlette>=0.47.3
75
87
  Requires-Dist: typing-inspection>=0.4.1
76
88
  Requires-Dist: typing_extensions>=4.15.0
89
+ Requires-Dist: ua-parser>=1.0.1
90
+ Requires-Dist: ua-parser-builtins>=0.18.0.post1
77
91
  Requires-Dist: urllib3>=2.5.0
92
+ Requires-Dist: user-agents>=2.2.0
78
93
  Requires-Dist: virtualenv>=20.34.0
79
94
  Requires-Dist: zipp>=3.23.0
80
95
  Dynamic: license-file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-database
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Database package for MaleoSuite
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -18,7 +18,7 @@ Requires-Dist: cffi>=1.17.1
18
18
  Requires-Dist: cfgv>=3.4.0
19
19
  Requires-Dist: charset-normalizer>=3.4.3
20
20
  Requires-Dist: click>=8.2.1
21
- Requires-Dist: cryptography>=45.0.6
21
+ Requires-Dist: cryptography>=45.0.7
22
22
  Requires-Dist: distlib>=0.4.0
23
23
  Requires-Dist: dnspython>=2.7.0
24
24
  Requires-Dist: elastic-transport>=9.1.0
@@ -31,25 +31,35 @@ Requires-Dist: google-cloud-appengine-logging>=1.6.2
31
31
  Requires-Dist: google-cloud-audit-log>=0.3.2
32
32
  Requires-Dist: google-cloud-core>=2.4.3
33
33
  Requires-Dist: google-cloud-logging>=3.12.1
34
+ Requires-Dist: google-cloud-pubsub>=2.31.1
34
35
  Requires-Dist: googleapis-common-protos>=1.70.0
35
36
  Requires-Dist: greenlet>=3.2.4
36
37
  Requires-Dist: grpc-google-iam-v1>=0.14.2
37
38
  Requires-Dist: grpcio>=1.74.0
38
39
  Requires-Dist: grpcio-status>=1.74.0
40
+ Requires-Dist: h11>=0.16.0
41
+ Requires-Dist: httpcore>=1.0.9
42
+ Requires-Dist: httpx>=0.28.1
39
43
  Requires-Dist: identify>=2.6.13
40
44
  Requires-Dist: idna>=3.10
41
45
  Requires-Dist: importlib_metadata>=8.7.0
42
- Requires-Dist: maleo-constants>=0.0.2
43
- Requires-Dist: maleo-enums>=0.0.3
44
- Requires-Dist: maleo-logging>=0.0.2
45
- Requires-Dist: maleo-mixins>=0.0.6
46
+ Requires-Dist: maleo-constants>=0.0.6
47
+ Requires-Dist: maleo-dtos>=0.0.11
48
+ Requires-Dist: maleo-enums>=0.0.6
49
+ Requires-Dist: maleo-exceptions>=0.0.12
50
+ Requires-Dist: maleo-logging>=0.0.6
51
+ Requires-Dist: maleo-mixins>=0.0.12
52
+ Requires-Dist: maleo-schemas>=0.0.14
46
53
  Requires-Dist: maleo-types-base>=0.0.2
47
- Requires-Dist: maleo-types-enums>=0.0.2
48
- Requires-Dist: maleo-utils>=0.0.3
54
+ Requires-Dist: maleo-types-controllers>=0.0.1
55
+ Requires-Dist: maleo-types-enums>=0.0.4
56
+ Requires-Dist: maleo-utils>=0.0.4
49
57
  Requires-Dist: motor>=3.7.1
50
58
  Requires-Dist: mypy_extensions>=1.1.0
51
59
  Requires-Dist: nodeenv>=1.9.1
52
60
  Requires-Dist: opentelemetry-api>=1.36.0
61
+ Requires-Dist: opentelemetry-sdk>=1.36.0
62
+ Requires-Dist: opentelemetry-semantic-conventions>=0.57b0
53
63
  Requires-Dist: packaging>=25.0
54
64
  Requires-Dist: pathspec>=0.12.1
55
65
  Requires-Dist: platformdirs>=4.4.0
@@ -61,9 +71,11 @@ Requires-Dist: pyasn1_modules>=0.4.2
61
71
  Requires-Dist: pycparser>=2.22
62
72
  Requires-Dist: pycryptodome>=3.23.0
63
73
  Requires-Dist: pydantic>=2.11.7
74
+ Requires-Dist: pydantic-settings>=2.10.1
64
75
  Requires-Dist: pydantic_core>=2.33.2
65
76
  Requires-Dist: pymongo>=4.14.1
66
77
  Requires-Dist: python-dateutil>=2.9.0.post0
78
+ Requires-Dist: python-dotenv>=1.1.1
67
79
  Requires-Dist: PyYAML>=6.0.2
68
80
  Requires-Dist: redis>=6.4.0
69
81
  Requires-Dist: requests>=2.32.5
@@ -74,7 +86,10 @@ Requires-Dist: SQLAlchemy>=2.0.43
74
86
  Requires-Dist: starlette>=0.47.3
75
87
  Requires-Dist: typing-inspection>=0.4.1
76
88
  Requires-Dist: typing_extensions>=4.15.0
89
+ Requires-Dist: ua-parser>=1.0.1
90
+ Requires-Dist: ua-parser-builtins>=0.18.0.post1
77
91
  Requires-Dist: urllib3>=2.5.0
92
+ Requires-Dist: user-agents>=2.2.0
78
93
  Requires-Dist: virtualenv>=20.34.0
79
94
  Requires-Dist: zipp>=3.23.0
80
95
  Dynamic: license-file
@@ -7,6 +7,7 @@ maleo_database.egg-info/dependency_links.txt
7
7
  maleo_database.egg-info/requires.txt
8
8
  maleo_database.egg-info/top_level.txt
9
9
  src/__init__.py
10
+ src/dtos.py
10
11
  src/enums.py
11
12
  src/config/__init__.py
12
13
  src/config/additional.py
@@ -14,16 +15,9 @@ src/config/connection.py
14
15
  src/config/identifier.py
15
16
  src/config/pooling.py
16
17
  src/managers/__init__.py
18
+ src/managers/client.py
19
+ src/managers/engine.py
17
20
  src/managers/session.py
18
- src/managers/clients/__init__.py
19
- src/managers/clients/elasticsearch.py
20
- src/managers/clients/mongodb.py
21
- src/managers/clients/redis.py
22
- src/managers/engines/__init__.py
23
- src/managers/engines/mysql.py
24
- src/managers/engines/postgresql.py
25
- src/managers/engines/sqlite.py
26
- src/managers/engines/sqlserver.py
27
21
  src/orm/__init__.py
28
22
  src/orm/base.py
29
23
  src/orm/queries.py
@@ -9,7 +9,7 @@ cffi>=1.17.1
9
9
  cfgv>=3.4.0
10
10
  charset-normalizer>=3.4.3
11
11
  click>=8.2.1
12
- cryptography>=45.0.6
12
+ cryptography>=45.0.7
13
13
  distlib>=0.4.0
14
14
  dnspython>=2.7.0
15
15
  elastic-transport>=9.1.0
@@ -22,25 +22,35 @@ google-cloud-appengine-logging>=1.6.2
22
22
  google-cloud-audit-log>=0.3.2
23
23
  google-cloud-core>=2.4.3
24
24
  google-cloud-logging>=3.12.1
25
+ google-cloud-pubsub>=2.31.1
25
26
  googleapis-common-protos>=1.70.0
26
27
  greenlet>=3.2.4
27
28
  grpc-google-iam-v1>=0.14.2
28
29
  grpcio>=1.74.0
29
30
  grpcio-status>=1.74.0
31
+ h11>=0.16.0
32
+ httpcore>=1.0.9
33
+ httpx>=0.28.1
30
34
  identify>=2.6.13
31
35
  idna>=3.10
32
36
  importlib_metadata>=8.7.0
33
- maleo-constants>=0.0.2
34
- maleo-enums>=0.0.3
35
- maleo-logging>=0.0.2
36
- maleo-mixins>=0.0.6
37
+ maleo-constants>=0.0.6
38
+ maleo-dtos>=0.0.11
39
+ maleo-enums>=0.0.6
40
+ maleo-exceptions>=0.0.12
41
+ maleo-logging>=0.0.6
42
+ maleo-mixins>=0.0.12
43
+ maleo-schemas>=0.0.14
37
44
  maleo-types-base>=0.0.2
38
- maleo-types-enums>=0.0.2
39
- maleo-utils>=0.0.3
45
+ maleo-types-controllers>=0.0.1
46
+ maleo-types-enums>=0.0.4
47
+ maleo-utils>=0.0.4
40
48
  motor>=3.7.1
41
49
  mypy_extensions>=1.1.0
42
50
  nodeenv>=1.9.1
43
51
  opentelemetry-api>=1.36.0
52
+ opentelemetry-sdk>=1.36.0
53
+ opentelemetry-semantic-conventions>=0.57b0
44
54
  packaging>=25.0
45
55
  pathspec>=0.12.1
46
56
  platformdirs>=4.4.0
@@ -52,9 +62,11 @@ pyasn1_modules>=0.4.2
52
62
  pycparser>=2.22
53
63
  pycryptodome>=3.23.0
54
64
  pydantic>=2.11.7
65
+ pydantic-settings>=2.10.1
55
66
  pydantic_core>=2.33.2
56
67
  pymongo>=4.14.1
57
68
  python-dateutil>=2.9.0.post0
69
+ python-dotenv>=1.1.1
58
70
  PyYAML>=6.0.2
59
71
  redis>=6.4.0
60
72
  requests>=2.32.5
@@ -65,6 +77,9 @@ SQLAlchemy>=2.0.43
65
77
  starlette>=0.47.3
66
78
  typing-inspection>=0.4.1
67
79
  typing_extensions>=4.15.0
80
+ ua-parser>=1.0.1
81
+ ua-parser-builtins>=0.18.0.post1
68
82
  urllib3>=2.5.0
83
+ user-agents>=2.2.0
69
84
  virtualenv>=20.34.0
70
85
  zipp>=3.23.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo-database"
7
- version = "0.0.4"
7
+ version = "0.0.6"
8
8
  description = "Database package for MaleoSuite"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -24,7 +24,7 @@ dependencies = [
24
24
  "cfgv>=3.4.0",
25
25
  "charset-normalizer>=3.4.3",
26
26
  "click>=8.2.1",
27
- "cryptography>=45.0.6",
27
+ "cryptography>=45.0.7",
28
28
  "distlib>=0.4.0",
29
29
  "dnspython>=2.7.0",
30
30
  "elastic-transport>=9.1.0",
@@ -37,25 +37,35 @@ dependencies = [
37
37
  "google-cloud-audit-log>=0.3.2",
38
38
  "google-cloud-core>=2.4.3",
39
39
  "google-cloud-logging>=3.12.1",
40
+ "google-cloud-pubsub>=2.31.1",
40
41
  "googleapis-common-protos>=1.70.0",
41
42
  "greenlet>=3.2.4",
42
43
  "grpc-google-iam-v1>=0.14.2",
43
44
  "grpcio>=1.74.0",
44
45
  "grpcio-status>=1.74.0",
46
+ "h11>=0.16.0",
47
+ "httpcore>=1.0.9",
48
+ "httpx>=0.28.1",
45
49
  "identify>=2.6.13",
46
50
  "idna>=3.10",
47
51
  "importlib_metadata>=8.7.0",
48
- "maleo-constants>=0.0.2",
49
- "maleo-enums>=0.0.3",
50
- "maleo-logging>=0.0.2",
51
- "maleo-mixins>=0.0.6",
52
+ "maleo-constants>=0.0.6",
53
+ "maleo-dtos>=0.0.11",
54
+ "maleo-enums>=0.0.6",
55
+ "maleo-exceptions>=0.0.12",
56
+ "maleo-logging>=0.0.6",
57
+ "maleo-mixins>=0.0.12",
58
+ "maleo-schemas>=0.0.14",
52
59
  "maleo-types-base>=0.0.2",
53
- "maleo-types-enums>=0.0.2",
54
- "maleo-utils>=0.0.3",
60
+ "maleo-types-controllers>=0.0.1",
61
+ "maleo-types-enums>=0.0.4",
62
+ "maleo-utils>=0.0.4",
55
63
  "motor>=3.7.1",
56
64
  "mypy_extensions>=1.1.0",
57
65
  "nodeenv>=1.9.1",
58
66
  "opentelemetry-api>=1.36.0",
67
+ "opentelemetry-sdk>=1.36.0",
68
+ "opentelemetry-semantic-conventions>=0.57b0",
59
69
  "packaging>=25.0",
60
70
  "pathspec>=0.12.1",
61
71
  "platformdirs>=4.4.0",
@@ -67,9 +77,11 @@ dependencies = [
67
77
  "pycparser>=2.22",
68
78
  "pycryptodome>=3.23.0",
69
79
  "pydantic>=2.11.7",
80
+ "pydantic-settings>=2.10.1",
70
81
  "pydantic_core>=2.33.2",
71
82
  "pymongo>=4.14.1",
72
83
  "python-dateutil>=2.9.0.post0",
84
+ "python-dotenv>=1.1.1",
73
85
  "PyYAML>=6.0.2",
74
86
  "redis>=6.4.0",
75
87
  "requests>=2.32.5",
@@ -80,7 +92,10 @@ dependencies = [
80
92
  "starlette>=0.47.3",
81
93
  "typing-inspection>=0.4.1",
82
94
  "typing_extensions>=4.15.0",
95
+ "ua-parser>=1.0.1",
96
+ "ua-parser-builtins>=0.18.0.post1",
83
97
  "urllib3>=2.5.0",
98
+ "user-agents>=2.2.0",
84
99
  "virtualenv>=20.34.0",
85
100
  "zipp>=3.23.0",
86
101
  ]
@@ -90,8 +105,6 @@ packages = [
90
105
  "maleo.database",
91
106
  "maleo.database.config",
92
107
  "maleo.database.managers",
93
- "maleo.database.managers.clients",
94
- "maleo.database.managers.engines",
95
108
  "maleo.database.orm",
96
109
  "maleo.database.orm.models",
97
110
  "maleo.database.orm.models.mixins",
@@ -101,8 +114,6 @@ packages = [
101
114
  "maleo.database" = ["*.json", "*.yaml"]
102
115
  "maleo.database.config" = ["*.json", "*.yaml"]
103
116
  "maleo.database.managers" = ["*.json", "*.yaml"]
104
- "maleo.database.managers.clients" = ["*.json", "*.yaml"]
105
- "maleo.database.managers.engines" = ["*.json", "*.yaml"]
106
117
  "maleo.database.orm" = ["*.json", "*.yaml"]
107
118
  "maleo.database.orm.models" = ["*.json", "*.yaml"]
108
119
  "maleo.database.orm.models.mixins" = ["*.json", "*.yaml"]
@@ -111,8 +122,6 @@ packages = [
111
122
  "maleo.database" = "src"
112
123
  "maleo.database.config" = "src/config"
113
124
  "maleo.database.managers" = "src/managers"
114
- "maleo.database.managers.clients" = "src/managers/clients"
115
- "maleo.database.managers.engines" = "src/managers/engines"
116
125
  "maleo.database.orm" = "src/orm"
117
126
  "maleo.database.orm.models" = "src/orm/models"
118
127
  "maleo.database.orm.models.mixins" = "src/orm/models/mixins"
@@ -0,0 +1,278 @@
1
+ from elasticsearch import AsyncElasticsearch, Elasticsearch
2
+ from motor.motor_asyncio import AsyncIOMotorClient
3
+ from pydantic import BaseModel, Field
4
+ from pymongo import MongoClient
5
+ from redis.asyncio import Redis as AsyncRedis
6
+ from redis import Redis as SyncRedis
7
+ from sqlalchemy.engine import create_engine as create_sync_engine, Engine
8
+ from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine
9
+ from typing import Generic, Literal, TypeVar, Union, overload
10
+ from maleo.types.base.dict import StringToAnyDict
11
+ from ..enums import Connection
12
+ from .additional import AdditionalConfigT, RedisAdditionalConfig
13
+ from .connection import (
14
+ ConnectionConfigT,
15
+ PostgreSQLConnectionConfig,
16
+ MySQLConnectionConfig,
17
+ SQLiteConnectionConfig,
18
+ SQLServerConnectionConfig,
19
+ MongoDBConnectionConfig,
20
+ RedisConnectionConfig,
21
+ ElasticsearchConnectionConfig,
22
+ )
23
+ from .identifier import DatabaseIdentifierConfig
24
+ from .pooling import (
25
+ PoolingConfigT,
26
+ PostgreSQLPoolingConfig,
27
+ MySQLPoolingConfig,
28
+ SQLitePoolingConfig,
29
+ SQLServerPoolingConfig,
30
+ MongoDBPoolingConfig,
31
+ RedisPoolingConfig,
32
+ ElasticsearchPoolingConfig,
33
+ )
34
+
35
+
36
+ class BaseDatabaseConfig(
37
+ BaseModel, Generic[ConnectionConfigT, PoolingConfigT, AdditionalConfigT]
38
+ ):
39
+ """Base configuration for database."""
40
+
41
+ identifier: DatabaseIdentifierConfig = Field(..., description="Identifier config")
42
+ connection: ConnectionConfigT = Field(..., description="Connection config")
43
+ pooling: PoolingConfigT = Field(..., description="Pooling config")
44
+ additional: AdditionalConfigT = Field(..., description="Additional config")
45
+
46
+
47
+ class MySQLDatabaseConfig(
48
+ BaseDatabaseConfig[
49
+ MySQLConnectionConfig,
50
+ MySQLPoolingConfig,
51
+ None,
52
+ ]
53
+ ):
54
+ additional: None = None
55
+
56
+ @property
57
+ def engine_kwargs(self) -> StringToAnyDict:
58
+ return {
59
+ **self.connection.engine_kwargs,
60
+ **self.pooling.engine_kwargs,
61
+ }
62
+
63
+ @overload
64
+ def create_engine(self, connection: Literal[Connection.ASYNC]) -> AsyncEngine: ...
65
+ @overload
66
+ def create_engine(self, connection: Literal[Connection.SYNC]) -> Engine: ...
67
+ def create_engine(self, connection: Connection) -> Union[AsyncEngine, Engine]:
68
+ url = self.connection.make_url(connection)
69
+ if connection is Connection.ASYNC:
70
+ return create_async_engine(url, **self.engine_kwargs)
71
+ elif connection is Connection.SYNC:
72
+ return create_sync_engine(url, **self.engine_kwargs)
73
+
74
+
75
+ class PostgreSQLDatabaseConfig(
76
+ BaseDatabaseConfig[
77
+ PostgreSQLConnectionConfig,
78
+ PostgreSQLPoolingConfig,
79
+ None,
80
+ ]
81
+ ):
82
+ additional: None = None
83
+
84
+ @property
85
+ def engine_kwargs(self) -> StringToAnyDict:
86
+ return {
87
+ **self.connection.engine_kwargs,
88
+ **self.pooling.engine_kwargs,
89
+ }
90
+
91
+ @overload
92
+ def create_engine(self, connection: Literal[Connection.ASYNC]) -> AsyncEngine: ...
93
+ @overload
94
+ def create_engine(self, connection: Literal[Connection.SYNC]) -> Engine: ...
95
+ def create_engine(self, connection: Connection) -> Union[AsyncEngine, Engine]:
96
+ url = self.connection.make_url(connection)
97
+ if connection is Connection.ASYNC:
98
+ return create_async_engine(url, **self.engine_kwargs)
99
+ elif connection is Connection.SYNC:
100
+ return create_sync_engine(url, **self.engine_kwargs)
101
+
102
+
103
+ class SQLiteDatabaseConfig(
104
+ BaseDatabaseConfig[
105
+ SQLiteConnectionConfig,
106
+ SQLitePoolingConfig,
107
+ None,
108
+ ]
109
+ ):
110
+ additional: None = None
111
+
112
+ @property
113
+ def engine_kwargs(self) -> StringToAnyDict:
114
+ return {
115
+ **self.connection.engine_kwargs,
116
+ **self.pooling.engine_kwargs,
117
+ }
118
+
119
+ @overload
120
+ def create_engine(self, connection: Literal[Connection.ASYNC]) -> AsyncEngine: ...
121
+ @overload
122
+ def create_engine(self, connection: Literal[Connection.SYNC]) -> Engine: ...
123
+ def create_engine(self, connection: Connection) -> Union[AsyncEngine, Engine]:
124
+ url = self.connection.make_url(connection)
125
+ if connection is Connection.ASYNC:
126
+ return create_async_engine(url, **self.engine_kwargs)
127
+ elif connection is Connection.SYNC:
128
+ return create_sync_engine(url, **self.engine_kwargs)
129
+
130
+
131
+ class SQLServerDatabaseConfig(
132
+ BaseDatabaseConfig[
133
+ SQLServerConnectionConfig,
134
+ SQLServerPoolingConfig,
135
+ None,
136
+ ]
137
+ ):
138
+ additional: None = None
139
+
140
+ @property
141
+ def engine_kwargs(self) -> StringToAnyDict:
142
+ return {
143
+ **self.connection.engine_kwargs,
144
+ **self.pooling.engine_kwargs,
145
+ }
146
+
147
+ @overload
148
+ def create_engine(self, connection: Literal[Connection.ASYNC]) -> AsyncEngine: ...
149
+ @overload
150
+ def create_engine(self, connection: Literal[Connection.SYNC]) -> Engine: ...
151
+ def create_engine(self, connection: Connection) -> Union[AsyncEngine, Engine]:
152
+ url = self.connection.make_url(connection)
153
+ if connection is Connection.ASYNC:
154
+ return create_async_engine(url, **self.engine_kwargs)
155
+ elif connection is Connection.SYNC:
156
+ return create_sync_engine(url, **self.engine_kwargs)
157
+
158
+
159
+ SQLConfigT = TypeVar(
160
+ "SQLConfigT",
161
+ PostgreSQLDatabaseConfig,
162
+ MySQLDatabaseConfig,
163
+ SQLiteDatabaseConfig,
164
+ SQLServerDatabaseConfig,
165
+ )
166
+
167
+
168
+ class ElasticsearchDatabaseConfig(
169
+ BaseDatabaseConfig[
170
+ ElasticsearchConnectionConfig,
171
+ ElasticsearchPoolingConfig,
172
+ None,
173
+ ]
174
+ ):
175
+ additional: None = None
176
+
177
+ @property
178
+ def client_kwargs(self) -> StringToAnyDict:
179
+ client_kwargs = {}
180
+
181
+ if self.connection.username and self.connection.password:
182
+ client_kwargs["http_auth"] = (
183
+ self.connection.username,
184
+ self.connection.password,
185
+ )
186
+
187
+ client_kwargs.update(self.pooling.client_kwargs)
188
+
189
+ return client_kwargs
190
+
191
+ @overload
192
+ def create_client(
193
+ self, connection: Literal[Connection.ASYNC]
194
+ ) -> AsyncElasticsearch: ...
195
+ @overload
196
+ def create_client(self, connection: Literal[Connection.SYNC]) -> Elasticsearch: ...
197
+ def create_client(
198
+ self, connection: Connection
199
+ ) -> Union[AsyncElasticsearch, Elasticsearch]:
200
+ hosts = [{"host": self.connection.host, "port": self.connection.port}]
201
+ if connection is Connection.ASYNC:
202
+ return AsyncElasticsearch(hosts, **self.client_kwargs)
203
+ else:
204
+ return Elasticsearch(hosts, **self.client_kwargs)
205
+
206
+
207
+ class MongoDBDatabaseConfig(
208
+ BaseDatabaseConfig[
209
+ MongoDBConnectionConfig,
210
+ MongoDBPoolingConfig,
211
+ None,
212
+ ]
213
+ ):
214
+ additional: None = None
215
+
216
+ @property
217
+ def client_kwargs(self) -> StringToAnyDict:
218
+ return self.pooling.client_kwargs
219
+
220
+ @overload
221
+ def create_client(
222
+ self, connection: Literal[Connection.ASYNC]
223
+ ) -> AsyncIOMotorClient: ...
224
+ @overload
225
+ def create_client(self, connection: Literal[Connection.SYNC]) -> MongoClient: ...
226
+ def create_client(
227
+ self, connection: Connection
228
+ ) -> Union[AsyncIOMotorClient, MongoClient]:
229
+ url = self.connection.make_url(connection)
230
+ if connection is Connection.ASYNC:
231
+ return AsyncIOMotorClient(url, **self.client_kwargs)
232
+ else:
233
+ return MongoClient(url, **self.client_kwargs)
234
+
235
+
236
+ class RedisDatabaseConfig(
237
+ BaseDatabaseConfig[
238
+ RedisConnectionConfig,
239
+ RedisPoolingConfig,
240
+ RedisAdditionalConfig,
241
+ ]
242
+ ):
243
+ additional: RedisAdditionalConfig = Field(..., description="Additional config")
244
+
245
+ @property
246
+ def client_kwargs(self) -> StringToAnyDict:
247
+ return self.pooling.client_kwargs
248
+
249
+ @overload
250
+ def create_client(self, connection: Literal[Connection.ASYNC]) -> AsyncRedis: ...
251
+ @overload
252
+ def create_client(self, connection: Literal[Connection.SYNC]) -> SyncRedis: ...
253
+ def create_client(self, connection: Connection) -> Union[AsyncRedis, SyncRedis]:
254
+ url = self.connection.make_url(connection)
255
+ if connection is Connection.ASYNC:
256
+ return AsyncRedis.from_url(url, **self.client_kwargs)
257
+ else:
258
+ return SyncRedis.from_url(url, **self.client_kwargs)
259
+
260
+
261
+ NoSQLConfigT = TypeVar(
262
+ "NoSQLConfigT",
263
+ ElasticsearchDatabaseConfig,
264
+ MongoDBDatabaseConfig,
265
+ RedisDatabaseConfig,
266
+ )
267
+
268
+
269
+ ConfigT = TypeVar(
270
+ "ConfigT",
271
+ PostgreSQLDatabaseConfig,
272
+ MySQLDatabaseConfig,
273
+ SQLiteDatabaseConfig,
274
+ SQLServerDatabaseConfig,
275
+ MongoDBDatabaseConfig,
276
+ RedisDatabaseConfig,
277
+ ElasticsearchDatabaseConfig,
278
+ )