reydb 1.2.4__py3-none-any.whl → 1.2.6__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 +6 -6
- reydb/rerror.py +5 -5
- reydb/rorm.py +49 -17
- {reydb-1.2.4.dist-info → reydb-1.2.6.dist-info}/METADATA +1 -1
- {reydb-1.2.4.dist-info → reydb-1.2.6.dist-info}/RECORD +7 -7
- {reydb-1.2.4.dist-info → reydb-1.2.6.dist-info}/WHEEL +0 -0
- {reydb-1.2.4.dist-info → reydb-1.2.6.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -24,7 +24,7 @@ from .rbase import DatabaseBase
|
|
24
24
|
|
25
25
|
|
26
26
|
__all__ = (
|
27
|
-
'
|
27
|
+
'DatabaseTableConfig',
|
28
28
|
'DatabaseConfigSuper',
|
29
29
|
'DatabaseConfig',
|
30
30
|
'DatabaseConfigAsync'
|
@@ -38,14 +38,14 @@ ConfigValueT = TypeVar('T', bound=ConfigValue) # Any.
|
|
38
38
|
DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
|
39
39
|
|
40
40
|
|
41
|
-
class
|
41
|
+
class DatabaseTableConfig(rorm.Model, table=True):
|
42
42
|
"""
|
43
43
|
Database `config` table model.
|
44
44
|
"""
|
45
45
|
|
46
46
|
__comment__ = 'Config data table.'
|
47
47
|
create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
|
48
|
-
update_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
|
48
|
+
update_time: rorm.Datetime = rorm.Field(field_default='ON UPDATE CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
|
49
49
|
key: str = rorm.Field(field_type=rorm.types.VARCHAR(50), key=True, comment='Config key.')
|
50
50
|
value: str = rorm.Field(field_type=rorm.types.TEXT, not_null=True, comment='Config value.')
|
51
51
|
type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, comment='Config value type.')
|
@@ -81,7 +81,7 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
|
|
81
81
|
self.db = db
|
82
82
|
|
83
83
|
|
84
|
-
def handle_build_db(self) -> tuple[list[type[
|
84
|
+
def handle_build_db(self) -> tuple[list[type[DatabaseTableConfig]], list[dict[str, Any]]] :
|
85
85
|
"""
|
86
86
|
Handle method of check and build database tables, by `self.db_names`.
|
87
87
|
|
@@ -91,10 +91,10 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
|
|
91
91
|
"""
|
92
92
|
|
93
93
|
# Set parameter.
|
94
|
-
TableConfig._set_name(self.db_names['config'])
|
95
94
|
|
96
95
|
## Table.
|
97
|
-
|
96
|
+
DatabaseTableConfig._set_name(self.db_names['config'])
|
97
|
+
tables = [DatabaseTableConfig]
|
98
98
|
|
99
99
|
## View stats.
|
100
100
|
views_stats = [
|
reydb/rerror.py
CHANGED
@@ -22,7 +22,7 @@ from .rbase import DatabaseBase
|
|
22
22
|
|
23
23
|
|
24
24
|
__all__ = (
|
25
|
-
'
|
25
|
+
'DatabaseTableError',
|
26
26
|
'DatabaseErrorSuper',
|
27
27
|
'DatabaseError',
|
28
28
|
'DatabaseErrorAsync'
|
@@ -32,7 +32,7 @@ __all__ = (
|
|
32
32
|
DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
|
33
33
|
|
34
34
|
|
35
|
-
class
|
35
|
+
class DatabaseTableError(rorm.Model, table=True):
|
36
36
|
"""
|
37
37
|
Database `error` table model.
|
38
38
|
"""
|
@@ -75,7 +75,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
75
75
|
self.db = db
|
76
76
|
|
77
77
|
|
78
|
-
def handle_build_db(self) -> tuple[list[type[
|
78
|
+
def handle_build_db(self) -> tuple[list[type[DatabaseTableError]], list[dict[str, Any]]]:
|
79
79
|
"""
|
80
80
|
Handle method of check and build database tables, by `self.db_names`.
|
81
81
|
|
@@ -85,10 +85,10 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
85
85
|
"""
|
86
86
|
|
87
87
|
# Set parameter.
|
88
|
-
TableError._set_name(self.db_names['error'])
|
89
88
|
|
90
89
|
## Table.
|
91
|
-
|
90
|
+
DatabaseTableError._set_name(self.db_names['error'])
|
91
|
+
tables = [DatabaseTableError]
|
92
92
|
|
93
93
|
## View stats.
|
94
94
|
views_stats = [
|
reydb/rorm.py
CHANGED
@@ -103,10 +103,11 @@ class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
|
|
103
103
|
kwargs : Type other key arguments.
|
104
104
|
"""
|
105
105
|
|
106
|
-
#
|
106
|
+
# Set parameter.
|
107
107
|
if '__annotations__' in attrs:
|
108
108
|
table_args = attrs.setdefault('__table_args__', {})
|
109
109
|
table_args['quote'] = True
|
110
|
+
table_name = name.lower()
|
110
111
|
|
111
112
|
## Charset.
|
112
113
|
attrs.setdefault('__charset__', 'utf8mb4')
|
@@ -114,7 +115,7 @@ class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
|
|
114
115
|
|
115
116
|
## Name.
|
116
117
|
if '__name__' in attrs:
|
117
|
-
attrs['__tablename__'] = attrs.pop('__name__')
|
118
|
+
attrs['__tablename__'] = table_name = attrs.pop('__name__')
|
118
119
|
|
119
120
|
## Comment.
|
120
121
|
if '__comment__' in attrs:
|
@@ -128,12 +129,43 @@ class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
|
|
128
129
|
sa_column_kwargs: dict = field.sa_column_kwargs
|
129
130
|
sa_column_kwargs.setdefault('name', __name__)
|
130
131
|
|
132
|
+
## Unique.
|
133
|
+
table = default_registry.metadata.tables.get(table_name)
|
134
|
+
if table is not None:
|
135
|
+
default_registry.metadata.remove(table)
|
136
|
+
|
131
137
|
# Super.
|
132
138
|
new_cls = super().__new__(cls, name, bases, attrs, **kwargs)
|
133
139
|
|
134
140
|
return new_cls
|
135
141
|
|
136
142
|
|
143
|
+
def __init__(
|
144
|
+
cls,
|
145
|
+
name: str,
|
146
|
+
bases: tuple[Type],
|
147
|
+
attrs: dict[str, Any],
|
148
|
+
**kwargs: Any
|
149
|
+
) -> None:
|
150
|
+
"""
|
151
|
+
Build type attributes.
|
152
|
+
"""
|
153
|
+
|
154
|
+
# Super.
|
155
|
+
super().__init__(name, bases, attrs, **kwargs)
|
156
|
+
|
157
|
+
# Set parameter.
|
158
|
+
if '__annotations__' in attrs:
|
159
|
+
table: Table = cls.__table__
|
160
|
+
for index in table.indexes:
|
161
|
+
index_name_prefix = ['u_', 'n_'][index.unique]
|
162
|
+
index_name = index_name_prefix + '_'.join(
|
163
|
+
column.key
|
164
|
+
for column in index.expressions
|
165
|
+
)
|
166
|
+
index.name = index_name
|
167
|
+
|
168
|
+
|
137
169
|
class DatabaseORMModelField(DatabaseORMBase, FieldInfo):
|
138
170
|
"""
|
139
171
|
Database ORM model filed type.
|
@@ -214,7 +246,7 @@ class DatabaseORMModelField(DatabaseORMBase, FieldInfo):
|
|
214
246
|
**kwargs : Other key arguments.
|
215
247
|
"""
|
216
248
|
|
217
|
-
#
|
249
|
+
# Set parameter.
|
218
250
|
kwargs = {
|
219
251
|
key: value
|
220
252
|
for key, value in kwargs.items()
|
@@ -578,7 +610,7 @@ class DatabaseORMSessionSuper(
|
|
578
610
|
Instance.
|
579
611
|
"""
|
580
612
|
|
581
|
-
#
|
613
|
+
# Set parameter.
|
582
614
|
if is_instance(model):
|
583
615
|
model = type(model)
|
584
616
|
|
@@ -605,7 +637,7 @@ class DatabaseORMSessionSuper(
|
|
605
637
|
Instance.
|
606
638
|
"""
|
607
639
|
print(model)
|
608
|
-
#
|
640
|
+
# Set parameter.
|
609
641
|
if is_instance(model):
|
610
642
|
model = type(model)
|
611
643
|
|
@@ -632,7 +664,7 @@ class DatabaseORMSessionSuper(
|
|
632
664
|
Instance.
|
633
665
|
"""
|
634
666
|
|
635
|
-
#
|
667
|
+
# Set parameter.
|
636
668
|
if is_instance(model):
|
637
669
|
model = type(model)
|
638
670
|
|
@@ -659,7 +691,7 @@ class DatabaseORMSessionSuper(
|
|
659
691
|
Instance.
|
660
692
|
"""
|
661
693
|
|
662
|
-
#
|
694
|
+
# Set parameter.
|
663
695
|
if is_instance(model):
|
664
696
|
model = type(model)
|
665
697
|
|
@@ -846,7 +878,7 @@ class DatabaseORMSession(
|
|
846
878
|
skip : Whether skip existing table.
|
847
879
|
"""
|
848
880
|
|
849
|
-
#
|
881
|
+
# Set parameter.
|
850
882
|
tables = [
|
851
883
|
model._get_table()
|
852
884
|
for model in models
|
@@ -875,7 +907,7 @@ class DatabaseORMSession(
|
|
875
907
|
skip : Skip not exist table.
|
876
908
|
"""
|
877
909
|
|
878
|
-
#
|
910
|
+
# Set parameter.
|
879
911
|
tables = [
|
880
912
|
model._get_table()
|
881
913
|
for model in models
|
@@ -906,7 +938,7 @@ class DatabaseORMSession(
|
|
906
938
|
With records ORM model instance or null.
|
907
939
|
"""
|
908
940
|
|
909
|
-
#
|
941
|
+
# Set parameter.
|
910
942
|
if is_instance(model):
|
911
943
|
model = type(model)
|
912
944
|
|
@@ -940,7 +972,7 @@ class DatabaseORMSession(
|
|
940
972
|
With records ORM model instance list.
|
941
973
|
"""
|
942
974
|
|
943
|
-
#
|
975
|
+
# Set parameter.
|
944
976
|
if is_instance(model):
|
945
977
|
model = type(model)
|
946
978
|
|
@@ -968,7 +1000,7 @@ class DatabaseORMSession(
|
|
968
1000
|
With records ORM model instance list.
|
969
1001
|
"""
|
970
1002
|
|
971
|
-
#
|
1003
|
+
# Set parameter.
|
972
1004
|
if is_instance(model):
|
973
1005
|
model = type(model)
|
974
1006
|
|
@@ -1212,7 +1244,7 @@ class DatabaseORMSessionAsync(
|
|
1212
1244
|
skip : Whether skip existing table.
|
1213
1245
|
"""
|
1214
1246
|
|
1215
|
-
#
|
1247
|
+
# Set parameter.
|
1216
1248
|
tables = [
|
1217
1249
|
model._get_table()
|
1218
1250
|
for model in models
|
@@ -1242,7 +1274,7 @@ class DatabaseORMSessionAsync(
|
|
1242
1274
|
skip : Skip not exist table.
|
1243
1275
|
"""
|
1244
1276
|
|
1245
|
-
#
|
1277
|
+
# Set parameter.
|
1246
1278
|
tables = [
|
1247
1279
|
model._get_table()
|
1248
1280
|
for model in models
|
@@ -1274,7 +1306,7 @@ class DatabaseORMSessionAsync(
|
|
1274
1306
|
With records ORM model instance or null.
|
1275
1307
|
"""
|
1276
1308
|
|
1277
|
-
#
|
1309
|
+
# Set parameter.
|
1278
1310
|
if is_instance(model):
|
1279
1311
|
model = type(model)
|
1280
1312
|
|
@@ -1308,7 +1340,7 @@ class DatabaseORMSessionAsync(
|
|
1308
1340
|
With records ORM model instance list.
|
1309
1341
|
"""
|
1310
1342
|
|
1311
|
-
#
|
1343
|
+
# Set parameter.
|
1312
1344
|
if is_instance(model):
|
1313
1345
|
model = type(model)
|
1314
1346
|
|
@@ -1336,7 +1368,7 @@ class DatabaseORMSessionAsync(
|
|
1336
1368
|
With records ORM model instance list.
|
1337
1369
|
"""
|
1338
1370
|
|
1339
|
-
#
|
1371
|
+
# Set parameter.
|
1340
1372
|
if is_instance(model):
|
1341
1373
|
model = type(model)
|
1342
1374
|
|
@@ -2,14 +2,14 @@ reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
|
2
2
|
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
3
|
reydb/rbase.py,sha256=vx37yV6LlWP89nWAfYyOf0Xm3N_e9eB8z5Mxe-aTEo4,8248
|
4
4
|
reydb/rbuild.py,sha256=imakdlqQXzQlbAukti3_REVU_h7IRRE3fwUk91LaIIM,80430
|
5
|
-
reydb/rconfig.py,sha256=
|
5
|
+
reydb/rconfig.py,sha256=JvNf9LU6CzD9eThM8BZz0EVJeDgALmX8JHpY_mXR5mg,19207
|
6
6
|
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
7
|
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
|
-
reydb/rerror.py,sha256=
|
8
|
+
reydb/rerror.py,sha256=Cmbcz5CgpI2ro7CbFHUYWP6zuiFJoxy_ENzSUNuuwe8,14924
|
9
9
|
reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
|
10
10
|
reydb/rinfo.py,sha256=LjrqTA7JJbWJsjXwV-zKpbE1htv-whg6239hoQj4yIU,18151
|
11
|
-
reydb/rorm.py,sha256=
|
12
|
-
reydb-1.2.
|
13
|
-
reydb-1.2.
|
14
|
-
reydb-1.2.
|
15
|
-
reydb-1.2.
|
11
|
+
reydb/rorm.py,sha256=baHqpNqnBaE1qQpsc5TaegJBbOhWnl748rPPzO7Ab6Q,42314
|
12
|
+
reydb-1.2.6.dist-info/METADATA,sha256=O94lfy2GvYZTAHXYwRlts15238S9IqTmoTIyDiwmJyo,1621
|
13
|
+
reydb-1.2.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
reydb-1.2.6.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
+
reydb-1.2.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|