reydb 1.2.21__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/rdb.py
CHANGED
@@ -9,9 +9,8 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import TypeVar, Generic,
|
13
|
-
from
|
14
|
-
from reykit.rbase import CallableT, Null, throw, 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
|
@@ -42,43 +41,67 @@ class DatabaseSuper(DatabaseBase, Generic[DatabaseEngineT]):
|
|
42
41
|
self.__engine_dict: dict[str, DatabaseEngineT] = {}
|
43
42
|
|
44
43
|
|
45
|
-
@
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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:
|
51
67
|
"""
|
52
|
-
|
68
|
+
Build instance attributes.
|
53
69
|
|
54
70
|
Parameters
|
55
71
|
----------
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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.
|
62
87
|
"""
|
63
88
|
|
89
|
+
# Parameter.
|
90
|
+
match self:
|
91
|
+
case Database():
|
92
|
+
engine_type = DatabaseEngine
|
93
|
+
case DatabaseAsync():
|
94
|
+
engine_type = DatabaseEngineAsync
|
64
95
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# Build.
|
69
|
-
engine: DatabaseEngineT = engine_type(*args, **kwargs)
|
70
|
-
|
71
|
-
# Warning.
|
72
|
-
if engine.database in self.__engine_dict:
|
73
|
-
warn(f'database engine "{engine.database}" re registered.')
|
74
|
-
|
75
|
-
# Add.
|
76
|
-
self.__engine_dict[engine.database] = engine
|
77
|
-
|
78
|
-
return engine
|
96
|
+
# Create.
|
97
|
+
engine = engine_type(**kwargs)
|
79
98
|
|
99
|
+
# Add.
|
100
|
+
if name is None:
|
101
|
+
name = engine.database
|
102
|
+
self.__engine_dict[name] = engine
|
80
103
|
|
81
|
-
return
|
104
|
+
return engine
|
82
105
|
|
83
106
|
|
84
107
|
def __getattr__(self, database: str) -> DatabaseEngineT:
|
@@ -125,13 +148,7 @@ class Database(DatabaseSuper[DatabaseEngine]):
|
|
125
148
|
"""
|
126
149
|
|
127
150
|
|
128
|
-
__call__ = DatabaseSuper._wrap_add(DatabaseEngine, DatabaseEngine.__init__)
|
129
|
-
|
130
|
-
|
131
151
|
class DatabaseAsync(DatabaseSuper[DatabaseEngineAsync]):
|
132
152
|
"""
|
133
153
|
Asynchronous database type.
|
134
154
|
"""
|
135
|
-
|
136
|
-
|
137
|
-
__call__ = DatabaseSuper._wrap_add(DatabaseEngineAsync, DatabaseEngineAsync.__init__)
|
@@ -4,13 +4,13 @@ reydb/rbase.py,sha256=S3ip2PxvLn2Spgv5G_xd7xgC-U4wjEoAZ7Up25ZQvLk,8223
|
|
4
4
|
reydb/rbuild.py,sha256=6ZkU3LGkIk04KTPtd8fgTC4pX93p1tvbOhZWWEi-v5A,40846
|
5
5
|
reydb/rconfig.py,sha256=DFGTyoixqlSMGeWyd1os9K7YxnyY3RfgvPqQzZQlMQM,18161
|
6
6
|
reydb/rconn.py,sha256=K_k6cJ94yrPIFaSZ06enpguTWVPhDu67LHan41C1bRA,7023
|
7
|
-
reydb/rdb.py,sha256=
|
7
|
+
reydb/rdb.py,sha256=KAxSDuRgAnNuwS8xie7kTvwLWM9m97suF8qhC_q9yT4,3698
|
8
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
|