reydb 1.2.20__py3-none-any.whl → 1.2.22__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.
- reydb/rconfig.py +1 -1
- reydb/rdb.py +69 -40
- reydb/rengine.py +2 -2
- {reydb-1.2.20.dist-info → reydb-1.2.22.dist-info}/METADATA +1 -1
- {reydb-1.2.20.dist-info → reydb-1.2.22.dist-info}/RECORD +7 -7
- {reydb-1.2.20.dist-info → reydb-1.2.22.dist-info}/WHEEL +0 -0
- {reydb-1.2.20.dist-info → reydb-1.2.22.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -79,7 +79,7 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseEngineT]):
|
|
79
79
|
if type(self) == DatabaseConfig:
|
80
80
|
self.build_db()
|
81
81
|
elif type(self) == DatabaseConfigAsync:
|
82
|
-
engine.
|
82
|
+
engine.sync_engine.config.build_db()
|
83
83
|
self._checked = True
|
84
84
|
|
85
85
|
|
reydb/rdb.py
CHANGED
@@ -9,14 +9,20 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import TypeVar, Generic,
|
13
|
-
from
|
14
|
-
from reykit.rbase import CallableT, warn
|
12
|
+
from typing import Any, TypeVar, Generic, overload
|
13
|
+
from reykit.rbase import Null, throw
|
15
14
|
|
16
15
|
from .rbase import DatabaseBase
|
17
16
|
from .rengine import DatabaseEngine, DatabaseEngineAsync
|
18
17
|
|
19
18
|
|
19
|
+
__all__ = (
|
20
|
+
'DatabaseSuper',
|
21
|
+
'Database',
|
22
|
+
'DatabaseAsync'
|
23
|
+
)
|
24
|
+
|
25
|
+
|
20
26
|
DatabaseEngineT = TypeVar('DatabaseEngineT', DatabaseEngine, DatabaseEngineAsync)
|
21
27
|
|
22
28
|
|
@@ -35,46 +41,70 @@ class DatabaseSuper(DatabaseBase, Generic[DatabaseEngineT]):
|
|
35
41
|
self.__engine_dict: dict[str, DatabaseEngineT] = {}
|
36
42
|
|
37
43
|
|
38
|
-
@
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
@overload
|
45
|
+
def __call__(
|
46
|
+
self,
|
47
|
+
name: str | None = None,
|
48
|
+
*,
|
49
|
+
host: str,
|
50
|
+
port: int | str,
|
51
|
+
username: str,
|
52
|
+
password: str,
|
53
|
+
database: str,
|
54
|
+
pool_size: int = 5,
|
55
|
+
max_overflow: int = 10,
|
56
|
+
pool_timeout: float = 30.0,
|
57
|
+
pool_recycle: int | None = 3600,
|
58
|
+
echo: bool = False,
|
59
|
+
**query: str
|
60
|
+
) -> DatabaseEngineT: ...
|
61
|
+
|
62
|
+
def __call__(
|
63
|
+
self,
|
64
|
+
name: str | None = None,
|
65
|
+
**kwargs: Any
|
66
|
+
) -> DatabaseEngineT:
|
44
67
|
"""
|
45
|
-
|
68
|
+
Build instance attributes.
|
46
69
|
|
47
70
|
Parameters
|
48
71
|
----------
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
72
|
+
name : Database engine name, useed for index.
|
73
|
+
- `None`: Use database name.
|
74
|
+
host : Remote server database host.
|
75
|
+
port : Remote server database port.
|
76
|
+
username : Remote server database username.
|
77
|
+
password : Remote server database password.
|
78
|
+
database : Remote server database name.
|
79
|
+
pool_size : Number of connections `keep open`.
|
80
|
+
max_overflow : Number of connections `allowed overflow`.
|
81
|
+
pool_timeout : Number of seconds `wait create` connection.
|
82
|
+
pool_recycle : Number of seconds `recycle` connection.
|
83
|
+
- `None | Literal[-1]`: No recycle.
|
84
|
+
- `int`: Use this value.
|
85
|
+
echo : Whether report SQL execute information, not include ORM execute.
|
86
|
+
query : Remote server database parameters.
|
55
87
|
"""
|
56
88
|
|
89
|
+
# Parameter.
|
90
|
+
match self:
|
91
|
+
case Database():
|
92
|
+
engine_type = DatabaseEngine
|
93
|
+
case DatabaseAsync():
|
94
|
+
engine_type = DatabaseEngineAsync
|
57
95
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# Build.
|
62
|
-
engine: DatabaseEngineT = engine_type(*args, **kwargs)
|
63
|
-
|
64
|
-
# Warning.
|
65
|
-
if engine.database in self.__engine_dict:
|
66
|
-
warn(f'database engine "{engine.database}" re registered.')
|
67
|
-
|
68
|
-
# Add.
|
69
|
-
self.__engine_dict[engine.database] = engine
|
96
|
+
# Create.
|
97
|
+
engine = engine_type(**kwargs)
|
70
98
|
|
71
|
-
|
99
|
+
# Add.
|
100
|
+
if name is None:
|
101
|
+
name = engine.database
|
102
|
+
self.__engine_dict[name] = engine
|
72
103
|
|
73
|
-
|
74
|
-
return func
|
104
|
+
return engine
|
75
105
|
|
76
106
|
|
77
|
-
def
|
107
|
+
def __getattr__(self, database: str) -> DatabaseEngineT:
|
78
108
|
"""
|
79
109
|
Get added database engine.
|
80
110
|
|
@@ -84,12 +114,17 @@ class DatabaseSuper(DatabaseBase, Generic[DatabaseEngineT]):
|
|
84
114
|
"""
|
85
115
|
|
86
116
|
# Get.
|
87
|
-
engine = self.__engine_dict
|
117
|
+
engine = self.__engine_dict.get(database, Null)
|
118
|
+
|
119
|
+
# Throw exception.
|
120
|
+
if engine == Null:
|
121
|
+
text = f"lack of database engine '{database}'"
|
122
|
+
throw(AssertionError, text=text)
|
88
123
|
|
89
124
|
return engine
|
90
125
|
|
91
126
|
|
92
|
-
|
127
|
+
__getitem__ = __getattr__
|
93
128
|
|
94
129
|
|
95
130
|
def __contains__(self, database: str) -> bool:
|
@@ -113,13 +148,7 @@ class Database(DatabaseSuper[DatabaseEngine]):
|
|
113
148
|
"""
|
114
149
|
|
115
150
|
|
116
|
-
__call__ = DatabaseSuper._wrap_add(DatabaseEngine, DatabaseEngine.__init__)
|
117
|
-
|
118
|
-
|
119
151
|
class DatabaseAsync(DatabaseSuper[DatabaseEngineAsync]):
|
120
152
|
"""
|
121
153
|
Asynchronous database type.
|
122
154
|
"""
|
123
|
-
|
124
|
-
|
125
|
-
__call__ = DatabaseSuper._wrap_add(DatabaseEngineAsync, DatabaseEngineAsync.__init__)
|
reydb/rengine.py
CHANGED
@@ -520,7 +520,7 @@ class DatabaseEngine(
|
|
520
520
|
|
521
521
|
|
522
522
|
@property
|
523
|
-
def
|
523
|
+
def async_engine(self) -> 'DatabaseEngineAsync':
|
524
524
|
"""
|
525
525
|
Same engine `DatabaseEngineAsync` instance.
|
526
526
|
"""
|
@@ -564,7 +564,7 @@ class DatabaseEngineAsync(
|
|
564
564
|
|
565
565
|
|
566
566
|
@property
|
567
|
-
def
|
567
|
+
def sync_engine(self) -> DatabaseEngine:
|
568
568
|
"""
|
569
569
|
Same engine `Database` instance.
|
570
570
|
"""
|
@@ -2,15 +2,15 @@ reydb/__init__.py,sha256=BnJsTzcwqeQ8-5Boqsehgcpc1eSDkv41v0kdb10gAgM,643
|
|
2
2
|
reydb/rall.py,sha256=5GI0yuwF72XypNZ1DYIxKizo2Z5pR88Uv0nUpHKYhCk,379
|
3
3
|
reydb/rbase.py,sha256=S3ip2PxvLn2Spgv5G_xd7xgC-U4wjEoAZ7Up25ZQvLk,8223
|
4
4
|
reydb/rbuild.py,sha256=6ZkU3LGkIk04KTPtd8fgTC4pX93p1tvbOhZWWEi-v5A,40846
|
5
|
-
reydb/rconfig.py,sha256=
|
5
|
+
reydb/rconfig.py,sha256=DFGTyoixqlSMGeWyd1os9K7YxnyY3RfgvPqQzZQlMQM,18161
|
6
6
|
reydb/rconn.py,sha256=K_k6cJ94yrPIFaSZ06enpguTWVPhDu67LHan41C1bRA,7023
|
7
|
-
reydb/rdb.py,sha256=
|
8
|
-
reydb/rengine.py,sha256=
|
7
|
+
reydb/rdb.py,sha256=KAxSDuRgAnNuwS8xie7kTvwLWM9m97suF8qhC_q9yT4,3698
|
8
|
+
reydb/rengine.py,sha256=qkpEsfHleia-bT7DBgERpSlZfszB5mLbRACtG-H2D-s,15640
|
9
9
|
reydb/rerror.py,sha256=M7RPXwywLYl5Vew7jfXxUxVnBrM1b_T6V9Izt4B8zI0,14791
|
10
10
|
reydb/rexec.py,sha256=hZe5SRbqo_aTpuB1vI2HXVx1FjtwvKGLRom3uzjTuqI,52949
|
11
11
|
reydb/rinfo.py,sha256=c5otyOikGMVnLFhPbtlgmnFBRR3NMP7xcmMW-LQdaQk,18314
|
12
12
|
reydb/rorm.py,sha256=mnfVf6fulTJ84EyjFqYijdAwdwaybBVvyZKNG4EhbwU,50065
|
13
|
-
reydb-1.2.
|
14
|
-
reydb-1.2.
|
15
|
-
reydb-1.2.
|
16
|
-
reydb-1.2.
|
13
|
+
reydb-1.2.22.dist-info/METADATA,sha256=pW3SVZyNIILKtdjf7dnRzGkQcAAKzmBi8LPfPCuBlE0,1647
|
14
|
+
reydb-1.2.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
reydb-1.2.22.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
16
|
+
reydb-1.2.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|