reydb 1.2.1__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/rbase.py +4 -4
- reydb/rbuild.py +1493 -13
- reydb/rconfig.py +27 -21
- reydb/rdb.py +2 -2
- reydb/rerror.py +29 -23
- reydb/rexec.py +20 -20
- reydb/rinfo.py +13 -13
- reydb/rorm.py +62 -24
- {reydb-1.2.1.dist-info → reydb-1.2.3.dist-info}/METADATA +1 -1
- reydb-1.2.3.dist-info/RECORD +15 -0
- reydb-1.2.1.dist-info/RECORD +0 -15
- {reydb-1.2.1.dist-info → reydb-1.2.3.dist-info}/WHEEL +0 -0
- {reydb-1.2.1.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,
|
@@ -19,8 +19,8 @@ from datetime import (
|
|
19
19
|
from reykit.rbase import Null, throw
|
20
20
|
|
21
21
|
from . import rdb
|
22
|
+
from . import rorm
|
22
23
|
from .rbase import DatabaseBase
|
23
|
-
from .rorm import DatabaseORM as orm
|
24
24
|
|
25
25
|
|
26
26
|
__all__ = (
|
@@ -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,25 +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: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
|
81
|
-
update_time: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
|
82
|
-
key: str = orm.Field(field_type=orm.types.VARCHAR(50), key=True, not_null=True, comment='Config key.')
|
83
|
-
value: str = orm.Field(field_type=orm.types.TEXT, not_null=True, comment='Config value.')
|
84
|
-
type: str = orm.Field(field_type=orm.types.VARCHAR(50), not_null=True, comment='Config value type.')
|
85
|
-
note: str = orm.Field(field_type=orm.types.VARCHAR(500), comment='Config note.')
|
86
|
-
|
87
|
-
tables = [Config]
|
93
|
+
tables = [self.Config]
|
88
94
|
|
89
95
|
## View stats.
|
90
96
|
views_stats = [
|
@@ -142,7 +148,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
|
|
142
148
|
Check and build database tables, by `self.db_names`.
|
143
149
|
"""
|
144
150
|
|
145
|
-
#
|
151
|
+
# Set parameter.
|
146
152
|
tables, views_stats = self.handle_build_db()
|
147
153
|
|
148
154
|
# Build.
|
@@ -265,7 +271,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
|
|
265
271
|
- `ConfigTable`: Config key and value and note.
|
266
272
|
"""
|
267
273
|
|
268
|
-
#
|
274
|
+
# Set parameter.
|
269
275
|
if type(data) == dict:
|
270
276
|
data = [
|
271
277
|
{
|
@@ -426,7 +432,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
|
|
426
432
|
value : Config value.
|
427
433
|
"""
|
428
434
|
|
429
|
-
#
|
435
|
+
# Set parameter.
|
430
436
|
if type(key_note) != str:
|
431
437
|
key, note = key_note
|
432
438
|
else:
|
@@ -467,7 +473,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
|
|
467
473
|
Asynchronous check and build database tables, by `self.db_names`.
|
468
474
|
"""
|
469
475
|
|
470
|
-
#
|
476
|
+
# Set parameter.
|
471
477
|
tables, views_stats = self.handle_build_db()
|
472
478
|
|
473
479
|
# Build.
|
@@ -590,7 +596,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
|
|
590
596
|
- `ConfigTable`: Config key and value and note.
|
591
597
|
"""
|
592
598
|
|
593
|
-
#
|
599
|
+
# Set parameter.
|
594
600
|
if type(data) == dict:
|
595
601
|
data = [
|
596
602
|
{
|
@@ -751,7 +757,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
|
|
751
757
|
value : Config value.
|
752
758
|
"""
|
753
759
|
|
754
|
-
#
|
760
|
+
# Set parameter.
|
755
761
|
if type(key_note) != str:
|
756
762
|
key, note = key_note
|
757
763
|
else:
|
reydb/rdb.py
CHANGED
@@ -113,7 +113,7 @@ class DatabaseSuper(
|
|
113
113
|
query : Remote server database parameters.
|
114
114
|
"""
|
115
115
|
|
116
|
-
#
|
116
|
+
# Set parameter.
|
117
117
|
if type(port) == str:
|
118
118
|
port = int(port)
|
119
119
|
|
@@ -237,7 +237,7 @@ class DatabaseSuper(
|
|
237
237
|
Engine object.
|
238
238
|
"""
|
239
239
|
|
240
|
-
#
|
240
|
+
# Set parameter.
|
241
241
|
engine_params = {
|
242
242
|
'url': self.url,
|
243
243
|
'pool_size': self.pool_size,
|
reydb/rerror.py
CHANGED
@@ -14,12 +14,11 @@ from collections.abc import Callable
|
|
14
14
|
from inspect import iscoroutinefunction
|
15
15
|
from traceback import StackSummary
|
16
16
|
from functools import wraps as functools_wraps
|
17
|
-
from datetime import datetime as Datetime
|
18
17
|
from reykit.rbase import T, Exit, catch_exc
|
19
18
|
|
20
19
|
from . import rdb
|
20
|
+
from . import rorm
|
21
21
|
from .rbase import DatabaseBase
|
22
|
-
from .rorm import DatabaseORM as orm
|
23
22
|
|
24
23
|
|
25
24
|
__all__ = (
|
@@ -40,6 +39,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
40
39
|
Attributes
|
41
40
|
----------
|
42
41
|
db_names : Database table name mapping dictionary.
|
42
|
+
Error : Database `error` table model.
|
43
43
|
"""
|
44
44
|
|
45
45
|
db_names = {
|
@@ -48,6 +48,16 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
48
48
|
}
|
49
49
|
|
50
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
|
+
|
51
61
|
def __init__(self, db: DatabaseT) -> None:
|
52
62
|
"""
|
53
63
|
Build instance attributes.
|
@@ -61,24 +71,20 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
61
71
|
self.db = db
|
62
72
|
|
63
73
|
|
64
|
-
def handle_build_db(self) ->
|
74
|
+
def handle_build_db(self) -> tuple[list[type[Error]], list[dict[str, Any]]]:
|
65
75
|
"""
|
66
76
|
Handle method of check and build database tables, by `self.db_names`.
|
77
|
+
|
78
|
+
Returns
|
79
|
+
-------
|
80
|
+
Build database parameter.
|
67
81
|
"""
|
68
82
|
|
69
|
-
#
|
83
|
+
# Set parameter.
|
84
|
+
self.Error._name(self.db_names['error'])
|
70
85
|
|
71
86
|
## Table.
|
72
|
-
|
73
|
-
__name__ = self.db_names['error']
|
74
|
-
__comment__ = 'Error log table.'
|
75
|
-
create_time: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Record create time.')
|
76
|
-
id: int = orm.Field(field_name='idd', field_type=orm.types_mysql.INTEGER(unsigned=True), key=True, key_auto=True, not_null=True, comment='ID.')
|
77
|
-
type: str = orm.Field(field_type=orm.types.VARCHAR(50), not_null=True, index_n=True, comment='Error type.')
|
78
|
-
data: str = orm.Field(field_type=orm.types.JSON, comment='Error data.')
|
79
|
-
stack: str = orm.Field(field_type=orm.types.JSON, comment='Error code traceback stack.')
|
80
|
-
note: str = orm.Field(field_type=orm.types.VARCHAR(500), comment='Error note.')
|
81
|
-
tables = [error]
|
87
|
+
tables = [self.Error]
|
82
88
|
|
83
89
|
## View stats.
|
84
90
|
views_stats = [
|
@@ -151,7 +157,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
|
|
151
157
|
note : Exception note.
|
152
158
|
"""
|
153
159
|
|
154
|
-
#
|
160
|
+
# Set parameter.
|
155
161
|
exc_type = type(exc).__name__
|
156
162
|
exc_data = list(exc.args) or None
|
157
163
|
exc_stack = [
|
@@ -185,7 +191,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
|
|
185
191
|
Check and build database tables, by `self.db_names`.
|
186
192
|
"""
|
187
193
|
|
188
|
-
#
|
194
|
+
# Set parameter.
|
189
195
|
tables, views_stats = self.handle_build_db()
|
190
196
|
|
191
197
|
# Build.
|
@@ -208,7 +214,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
|
|
208
214
|
note : Exception note.
|
209
215
|
"""
|
210
216
|
|
211
|
-
#
|
217
|
+
# Set parameter.
|
212
218
|
data = self.handle_record(exc, stack, note)
|
213
219
|
|
214
220
|
# Insert.
|
@@ -235,7 +241,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
|
|
235
241
|
filter_type : Exception types of not insert, but still throw exception.
|
236
242
|
"""
|
237
243
|
|
238
|
-
#
|
244
|
+
# Set parameter.
|
239
245
|
_, exc, stack = catch_exc()
|
240
246
|
|
241
247
|
# Filter.
|
@@ -293,7 +299,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
|
|
293
299
|
>>> func(*args, **kwargs)
|
294
300
|
"""
|
295
301
|
|
296
|
-
#
|
302
|
+
# Set parameter.
|
297
303
|
if issubclass(filter_type, BaseException):
|
298
304
|
filter_type = (filter_type,)
|
299
305
|
|
@@ -363,7 +369,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
|
|
363
369
|
Asynchrouous check and build database tables, by `self.db_names`.
|
364
370
|
"""
|
365
371
|
|
366
|
-
#
|
372
|
+
# Set parameter.
|
367
373
|
tables, views_stats = self.handle_build_db()
|
368
374
|
|
369
375
|
# Build.
|
@@ -386,7 +392,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
|
|
386
392
|
note : Exception note.
|
387
393
|
"""
|
388
394
|
|
389
|
-
#
|
395
|
+
# Set parameter.
|
390
396
|
data = self.handle_record(exc, stack, note)
|
391
397
|
|
392
398
|
# Insert.
|
@@ -413,7 +419,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
|
|
413
419
|
filter_type : Exception types of not insert, but still throw exception.
|
414
420
|
"""
|
415
421
|
|
416
|
-
#
|
422
|
+
# Set parameter.
|
417
423
|
_, exc, stack = catch_exc()
|
418
424
|
|
419
425
|
# Filter.
|
@@ -472,7 +478,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
|
|
472
478
|
>>> await func(*args, **kwargs)
|
473
479
|
"""
|
474
480
|
|
475
|
-
#
|
481
|
+
# Set parameter.
|
476
482
|
if issubclass(filter_type, BaseException):
|
477
483
|
filter_type = (filter_type,)
|
478
484
|
|
reydb/rexec.py
CHANGED
@@ -87,7 +87,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
87
87
|
Parameter `sql` and `data` and `report`.
|
88
88
|
"""
|
89
89
|
|
90
|
-
#
|
90
|
+
# Set parameter.
|
91
91
|
echo = get_first_notnone(echo, self.conn.db.echo)
|
92
92
|
sql = handle_sql(sql)
|
93
93
|
if data is None:
|
@@ -142,7 +142,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
142
142
|
Parameter `sql`.
|
143
143
|
"""
|
144
144
|
|
145
|
-
#
|
145
|
+
# Set parameter.
|
146
146
|
if type(path) == str:
|
147
147
|
database, table = self.conn.db.database, path
|
148
148
|
else:
|
@@ -240,7 +240,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
240
240
|
Parameter `sql` and `kwdata`.
|
241
241
|
"""
|
242
242
|
|
243
|
-
#
|
243
|
+
# Set parameter.
|
244
244
|
if type(path) == str:
|
245
245
|
database, table = self.conn.db.database, path
|
246
246
|
else:
|
@@ -383,7 +383,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
383
383
|
Parameter `sql` and `data`.
|
384
384
|
"""
|
385
385
|
|
386
|
-
#
|
386
|
+
# Set parameter.
|
387
387
|
if type(path) == str:
|
388
388
|
database, table = self.conn.db.database, path
|
389
389
|
else:
|
@@ -517,7 +517,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
517
517
|
Parameter `sql`.
|
518
518
|
"""
|
519
519
|
|
520
|
-
#
|
520
|
+
# Set parameter.
|
521
521
|
if type(path) == str:
|
522
522
|
database, table = self.conn.db.database, path
|
523
523
|
else:
|
@@ -580,7 +580,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
580
580
|
Parameter `sql`.
|
581
581
|
"""
|
582
582
|
|
583
|
-
#
|
583
|
+
# Set parameter.
|
584
584
|
if type(path) == str:
|
585
585
|
database, table = self.conn.db.database, path
|
586
586
|
else:
|
@@ -658,7 +658,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
658
658
|
Result object.
|
659
659
|
"""
|
660
660
|
|
661
|
-
#
|
661
|
+
# Set parameter.
|
662
662
|
sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
|
663
663
|
|
664
664
|
# Transaction.
|
@@ -755,7 +755,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
755
755
|
[{'id': 1, 'id_': 2}, ...]
|
756
756
|
"""
|
757
757
|
|
758
|
-
#
|
758
|
+
# Set parameter.
|
759
759
|
sql = self.handle_select(path, fields, where, group, having, order, limit)
|
760
760
|
|
761
761
|
# Execute SQL.
|
@@ -808,7 +808,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
808
808
|
[{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
|
809
809
|
"""
|
810
810
|
|
811
|
-
#
|
811
|
+
# Set parameter.
|
812
812
|
sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
|
813
813
|
|
814
814
|
# Execute SQL.
|
@@ -867,7 +867,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
867
867
|
[{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
|
868
868
|
"""
|
869
869
|
|
870
|
-
#
|
870
|
+
# Set parameter.
|
871
871
|
sql, data = self.handle_update(path, data, where_fields, **kwdata)
|
872
872
|
|
873
873
|
# Execute SQL.
|
@@ -913,7 +913,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
913
913
|
2
|
914
914
|
"""
|
915
915
|
|
916
|
-
#
|
916
|
+
# Set parameter.
|
917
917
|
sql = self.handle_delete(path, where, order, limit)
|
918
918
|
|
919
919
|
# Execute SQL.
|
@@ -964,7 +964,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
964
964
|
2
|
965
965
|
"""
|
966
966
|
|
967
|
-
#
|
967
|
+
# Set parameter.
|
968
968
|
sql = self.handle_copy(path, fields, where, limit)
|
969
969
|
|
970
970
|
# Execute SQL.
|
@@ -1145,7 +1145,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1145
1145
|
- When parameters `precision` is `greater than 0`, then return float.
|
1146
1146
|
"""
|
1147
1147
|
|
1148
|
-
#
|
1148
|
+
# Set parameter.
|
1149
1149
|
if len(thresholds) == 1:
|
1150
1150
|
second = thresholds[0]
|
1151
1151
|
else:
|
@@ -1187,7 +1187,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1187
1187
|
Result object.
|
1188
1188
|
"""
|
1189
1189
|
|
1190
|
-
#
|
1190
|
+
# Set parameter.
|
1191
1191
|
sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
|
1192
1192
|
|
1193
1193
|
# Transaction.
|
@@ -1301,7 +1301,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1301
1301
|
[{'id': 1, 'id_': 2}, ...]
|
1302
1302
|
"""
|
1303
1303
|
|
1304
|
-
#
|
1304
|
+
# Set parameter.
|
1305
1305
|
sql = self.handle_select(path, fields, where, group, having, order, limit)
|
1306
1306
|
|
1307
1307
|
# Execute SQL.
|
@@ -1354,7 +1354,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1354
1354
|
[{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
|
1355
1355
|
"""
|
1356
1356
|
|
1357
|
-
#
|
1357
|
+
# Set parameter.
|
1358
1358
|
sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
|
1359
1359
|
|
1360
1360
|
# Execute SQL.
|
@@ -1413,7 +1413,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1413
1413
|
[{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
|
1414
1414
|
"""
|
1415
1415
|
|
1416
|
-
#
|
1416
|
+
# Set parameter.
|
1417
1417
|
sql, data = self.handle_update(path, data, where_fields, **kwdata)
|
1418
1418
|
|
1419
1419
|
# Execute SQL.
|
@@ -1459,7 +1459,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1459
1459
|
2
|
1460
1460
|
"""
|
1461
1461
|
|
1462
|
-
#
|
1462
|
+
# Set parameter.
|
1463
1463
|
sql = self.handle_delete(path, where, order, limit)
|
1464
1464
|
|
1465
1465
|
# Execute SQL.
|
@@ -1510,7 +1510,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1510
1510
|
2
|
1511
1511
|
"""
|
1512
1512
|
|
1513
|
-
#
|
1513
|
+
# Set parameter.
|
1514
1514
|
sql = self.handle_copy(path, fields, where, limit)
|
1515
1515
|
|
1516
1516
|
# Execute SQL.
|
@@ -1689,7 +1689,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1689
1689
|
- When parameters `precision` is `greater than 0`, then return float.
|
1690
1690
|
"""
|
1691
1691
|
|
1692
|
-
#
|
1692
|
+
# Set parameter.
|
1693
1693
|
if len(thresholds) == 1:
|
1694
1694
|
second = thresholds[0]
|
1695
1695
|
else:
|
reydb/rinfo.py
CHANGED
@@ -75,7 +75,7 @@ class DatabaseInformationSchemaSuper(DatabaseInformationBase, Generic[DatabaseT]
|
|
75
75
|
Parameter `sql` and `filter_db`.
|
76
76
|
"""
|
77
77
|
|
78
|
-
#
|
78
|
+
# Set parameter.
|
79
79
|
filter_db = (
|
80
80
|
'information_schema',
|
81
81
|
'performance_schema',
|
@@ -193,7 +193,7 @@ class DatabaseInformationSchemaSuper(DatabaseInformationBase, Generic[DatabaseT]
|
|
193
193
|
Judge result.
|
194
194
|
"""
|
195
195
|
|
196
|
-
#
|
196
|
+
# Set parameter.
|
197
197
|
|
198
198
|
# Judge.
|
199
199
|
judge = (
|
@@ -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,21 +291,21 @@ 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
|
-------
|
298
298
|
Judge result.
|
299
299
|
"""
|
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)
|
@@ -395,7 +395,7 @@ class DatabaseInformationSchemaAsync(DatabaseInformationSchemaSuper['rdb.Databas
|
|
395
395
|
Judge result.
|
396
396
|
"""
|
397
397
|
|
398
|
-
#
|
398
|
+
# Set parameter.
|
399
399
|
if (
|
400
400
|
refresh
|
401
401
|
or self.db._schema is None
|