reydb 1.2.2__py3-none-any.whl → 1.2.3__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/rbuild.py +1480 -0
- reydb/rconfig.py +19 -12
- reydb/rerror.py +18 -11
- reydb/rinfo.py +9 -9
- reydb/rorm.py +22 -0
- {reydb-1.2.2.dist-info → reydb-1.2.3.dist-info}/METADATA +1 -1
- reydb-1.2.3.dist-info/RECORD +15 -0
- reydb-1.2.2.dist-info/RECORD +0 -15
- {reydb-1.2.2.dist-info → reydb-1.2.3.dist-info}/WHEEL +0 -0
- {reydb-1.2.2.dist-info → reydb-1.2.3.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import TypedDict, TypeVar, Generic
|
12
|
+
from typing import Any, TypedDict, TypeVar, Generic
|
13
13
|
from datetime import (
|
14
14
|
datetime as Datetime,
|
15
15
|
date as Date,
|
@@ -45,6 +45,7 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
|
|
45
45
|
Attributes
|
46
46
|
----------
|
47
47
|
db_names : Database table name mapping dictionary.
|
48
|
+
Config : Database `config` table model.
|
48
49
|
"""
|
49
50
|
|
50
51
|
db_names = {
|
@@ -53,6 +54,16 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
|
|
53
54
|
}
|
54
55
|
|
55
56
|
|
57
|
+
class Config(rorm.Model, table=True):
|
58
|
+
__comment__ = 'Config data table.'
|
59
|
+
create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
|
60
|
+
update_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
|
61
|
+
key: str = rorm.Field(field_type=rorm.types.VARCHAR(50), key=True, comment='Config key.')
|
62
|
+
value: str = rorm.Field(field_type=rorm.types.TEXT, not_null=True, comment='Config value.')
|
63
|
+
type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, comment='Config value type.')
|
64
|
+
note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Config note.')
|
65
|
+
|
66
|
+
|
56
67
|
def __init__(self, db: DatabaseT) -> None:
|
57
68
|
"""
|
58
69
|
Build instance attributes.
|
@@ -66,24 +77,20 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
|
|
66
77
|
self.db = db
|
67
78
|
|
68
79
|
|
69
|
-
def handle_build_db(self) ->
|
80
|
+
def handle_build_db(self) -> tuple[list[type[Config]], list[dict[str, Any]]] :
|
70
81
|
"""
|
71
82
|
Handle method of check and build database tables, by `self.db_names`.
|
83
|
+
|
84
|
+
Returns
|
85
|
+
-------
|
86
|
+
Build database parameter.
|
72
87
|
"""
|
73
88
|
|
74
89
|
# Set parameter.
|
90
|
+
self.Config._name(self.db_names['config'])
|
75
91
|
|
76
92
|
## Table.
|
77
|
-
|
78
|
-
__name__ = self.db_names['config']
|
79
|
-
__comment__ = 'Config data table.'
|
80
|
-
create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
|
81
|
-
update_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
|
82
|
-
key: str = rorm.Field(field_type=rorm.types.VARCHAR(50), key=True, comment='Config key.')
|
83
|
-
value: str = rorm.Field(field_type=rorm.types.TEXT, not_null=True, comment='Config value.')
|
84
|
-
type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, comment='Config value type.')
|
85
|
-
note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Config note.')
|
86
|
-
tables = [Config]
|
93
|
+
tables = [self.Config]
|
87
94
|
|
88
95
|
## View stats.
|
89
96
|
views_stats = [
|
reydb/rerror.py
CHANGED
@@ -39,6 +39,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
39
39
|
Attributes
|
40
40
|
----------
|
41
41
|
db_names : Database table name mapping dictionary.
|
42
|
+
Error : Database `error` table model.
|
42
43
|
"""
|
43
44
|
|
44
45
|
db_names = {
|
@@ -47,6 +48,16 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
47
48
|
}
|
48
49
|
|
49
50
|
|
51
|
+
class Error(rorm.Model, table=True):
|
52
|
+
__comment__ = 'Error log table.'
|
53
|
+
create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Record create time.')
|
54
|
+
id: int = rorm.Field(field_type=rorm.types_mysql.INTEGER(unsigned=True), key_auto=True, comment='ID.')
|
55
|
+
type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, index_n=True, comment='Error type.')
|
56
|
+
data: str = rorm.Field(field_type=rorm.types.JSON, comment='Error data.')
|
57
|
+
stack: str = rorm.Field(field_type=rorm.types.JSON, comment='Error code traceback stack.')
|
58
|
+
note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Error note.')
|
59
|
+
|
60
|
+
|
50
61
|
def __init__(self, db: DatabaseT) -> None:
|
51
62
|
"""
|
52
63
|
Build instance attributes.
|
@@ -60,24 +71,20 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
60
71
|
self.db = db
|
61
72
|
|
62
73
|
|
63
|
-
def handle_build_db(self) ->
|
74
|
+
def handle_build_db(self) -> tuple[list[type[Error]], list[dict[str, Any]]]:
|
64
75
|
"""
|
65
76
|
Handle method of check and build database tables, by `self.db_names`.
|
77
|
+
|
78
|
+
Returns
|
79
|
+
-------
|
80
|
+
Build database parameter.
|
66
81
|
"""
|
67
82
|
|
68
83
|
# Set parameter.
|
84
|
+
self.Error._name(self.db_names['error'])
|
69
85
|
|
70
86
|
## Table.
|
71
|
-
|
72
|
-
__name__ = self.db_names['error']
|
73
|
-
__comment__ = 'Error log table.'
|
74
|
-
create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Record create time.')
|
75
|
-
id: int = rorm.Field(field_type=rorm.types_mysql.INTEGER(unsigned=True), key_auto=True, comment='ID.')
|
76
|
-
type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, index_n=True, comment='Error type.')
|
77
|
-
data: str = rorm.Field(field_type=rorm.types.JSON, comment='Error data.')
|
78
|
-
stack: str = rorm.Field(field_type=rorm.types.JSON, comment='Error code traceback stack.')
|
79
|
-
note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Error note.')
|
80
|
-
tables = [error]
|
87
|
+
tables = [self.Error]
|
81
88
|
|
82
89
|
## View stats.
|
83
90
|
views_stats = [
|
reydb/rinfo.py
CHANGED
@@ -255,7 +255,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
255
255
|
self,
|
256
256
|
database: str,
|
257
257
|
*,
|
258
|
-
|
258
|
+
cache: bool = True
|
259
259
|
) -> bool: ...
|
260
260
|
|
261
261
|
@overload
|
@@ -264,7 +264,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
264
264
|
database: str,
|
265
265
|
*,
|
266
266
|
table: str,
|
267
|
-
|
267
|
+
cache: bool = True
|
268
268
|
) -> bool: ...
|
269
269
|
|
270
270
|
@overload
|
@@ -273,7 +273,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
273
273
|
database: str,
|
274
274
|
table: str,
|
275
275
|
column: str,
|
276
|
-
|
276
|
+
cache: bool = True
|
277
277
|
) -> bool: ...
|
278
278
|
|
279
279
|
def exist(
|
@@ -281,7 +281,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
281
281
|
database: str,
|
282
282
|
table: str | None = None,
|
283
283
|
column: str | None = None,
|
284
|
-
|
284
|
+
cache: bool = True
|
285
285
|
) -> bool:
|
286
286
|
"""
|
287
287
|
Judge database or table or column whether it exists.
|
@@ -291,7 +291,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
291
291
|
database : Database name.
|
292
292
|
table : Table name.
|
293
293
|
column : Column name.
|
294
|
-
|
294
|
+
cache : Whether use cache data, can improve efficiency.
|
295
295
|
|
296
296
|
Returns
|
297
297
|
-------
|
@@ -300,12 +300,12 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
|
|
300
300
|
|
301
301
|
# Set parameter.
|
302
302
|
if (
|
303
|
-
|
304
|
-
|
303
|
+
cache
|
304
|
+
and self.db._schema is not None
|
305
305
|
):
|
306
|
-
schema = self.schema()
|
307
|
-
else:
|
308
306
|
schema = self.db._schema
|
307
|
+
else:
|
308
|
+
schema = self.schema()
|
309
309
|
|
310
310
|
# Judge.
|
311
311
|
result = self.handle_exist(schema, database, table, column)
|
reydb/rorm.py
CHANGED
@@ -327,6 +327,28 @@ class DatabaseORMModel(DatabaseORMBase, SQLModel, metaclass=model_metaclass):
|
|
327
327
|
return table
|
328
328
|
|
329
329
|
|
330
|
+
@classmethod
|
331
|
+
def _name(cls_or_self, name: str) -> None:
|
332
|
+
"""
|
333
|
+
Set database table name.
|
334
|
+
"""
|
335
|
+
|
336
|
+
# Get.
|
337
|
+
table = cls_or_self._table()
|
338
|
+
table.name = name
|
339
|
+
|
340
|
+
|
341
|
+
@classmethod
|
342
|
+
def _comment(cls_or_self, comment: str) -> None:
|
343
|
+
"""
|
344
|
+
Set database table comment.
|
345
|
+
"""
|
346
|
+
|
347
|
+
# Get.
|
348
|
+
table = cls_or_self._table()
|
349
|
+
table.comment = comment
|
350
|
+
|
351
|
+
|
330
352
|
@property
|
331
353
|
def _m(self):
|
332
354
|
"""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
2
|
+
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
|
+
reydb/rbase.py,sha256=vx37yV6LlWP89nWAfYyOf0Xm3N_e9eB8z5Mxe-aTEo4,8248
|
4
|
+
reydb/rbuild.py,sha256=8frMtmY8gKc-uYYaJPso9sm8IS3_CyTHrL_F0Wv5RI0,80554
|
5
|
+
reydb/rconfig.py,sha256=g428a0npVNgB3PMJiEpVRPwyvWm63G9KLcEru4-vPTU,19144
|
6
|
+
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
|
+
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
|
+
reydb/rerror.py,sha256=LcXyinipQw-saQxGwbkXU4BTOjb29RMX9hnAFidJN3Q,14871
|
9
|
+
reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
|
10
|
+
reydb/rinfo.py,sha256=LjrqTA7JJbWJsjXwV-zKpbE1htv-whg6239hoQj4yIU,18151
|
11
|
+
reydb/rorm.py,sha256=AVV50cC5Vm8pT6gIeBUAelXd3OpdQSldPsZltL8ceOg,41375
|
12
|
+
reydb-1.2.3.dist-info/METADATA,sha256=IULuCfrYhhcnoLjLulnsgEy4R_Dzc9s5P9IrhRCVsAM,1621
|
13
|
+
reydb-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
reydb-1.2.3.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
+
reydb-1.2.3.dist-info/RECORD,,
|
reydb-1.2.2.dist-info/RECORD
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
2
|
-
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
|
-
reydb/rbase.py,sha256=vx37yV6LlWP89nWAfYyOf0Xm3N_e9eB8z5Mxe-aTEo4,8248
|
4
|
-
reydb/rbuild.py,sha256=rmwfkjxjhavcbyn-V0ZTqwKNq3wKmgvHng8p5I0dghQ,40281
|
5
|
-
reydb/rconfig.py,sha256=5ZfFQwgt6JI5k1luv7PIj3H9Izuc6KNMOCFCJGBb1rQ,18998
|
6
|
-
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
|
-
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
|
-
reydb/rerror.py,sha256=renVDvi5e6-AC-y2KPksARPRX978WFh0Hqa9yfl9j1A,14735
|
9
|
-
reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
|
10
|
-
reydb/rinfo.py,sha256=9qpVFqFwMol5_n9gE3zYLv9Fn5r2EuVD5ibgQkSXYyw,18168
|
11
|
-
reydb/rorm.py,sha256=X99AKlpMQk3et9_3x1ddpKn1BxZRULLG8x_opYbWVX8,40934
|
12
|
-
reydb-1.2.2.dist-info/METADATA,sha256=J_Jq9TRbL2LRW154knFoOtwv8wWVQQqhfup0YTfEwRM,1621
|
13
|
-
reydb-1.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
-
reydb-1.2.2.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
-
reydb-1.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|