reydb 1.2.0__py3-none-any.whl → 1.2.2__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/__init__.py +1 -1
- reydb/rall.py +1 -1
- reydb/rbase.py +4 -4
- reydb/rbuild.py +13 -13
- reydb/rconfig.py +24 -20
- reydb/rdb.py +61 -41
- reydb/rerror.py +27 -23
- reydb/rexec.py +124 -123
- reydb/{rparam.py → rinfo.py} +54 -47
- reydb/rorm.py +40 -24
- {reydb-1.2.0.dist-info → reydb-1.2.2.dist-info}/METADATA +1 -1
- reydb-1.2.2.dist-info/RECORD +15 -0
- reydb-1.2.0.dist-info/RECORD +0 -15
- {reydb-1.2.0.dist-info → reydb-1.2.2.dist-info}/WHEEL +0 -0
- {reydb-1.2.0.dist-info → reydb-1.2.2.dist-info}/licenses/LICENSE +0 -0
reydb/rexec.py
CHANGED
@@ -18,7 +18,7 @@ from reykit.rdata import FunctionGenerator
|
|
18
18
|
from reykit.rmonkey import monkey_sqlalchemy_result_more_fetch, monkey_sqlalchemy_row_index_field
|
19
19
|
from reykit.rrand import randn
|
20
20
|
from reykit.rre import findall
|
21
|
-
from reykit.rstdout import echo
|
21
|
+
from reykit.rstdout import echo as recho
|
22
22
|
from reykit.rtable import TableData, Table
|
23
23
|
from reykit.rtime import TimeMark, time_to
|
24
24
|
from reykit.rwrap import wrap_runtime
|
@@ -67,7 +67,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
67
67
|
self,
|
68
68
|
sql: str | TextClause,
|
69
69
|
data: TableData | None = None,
|
70
|
-
|
70
|
+
echo: bool | None = None,
|
71
71
|
**kwdata: Any
|
72
72
|
) -> tuple[TextClause, list[dict], bool]:
|
73
73
|
"""
|
@@ -77,8 +77,8 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
77
77
|
----------
|
78
78
|
sql : SQL in method `sqlalchemy.text` format, or `TextClause` object.
|
79
79
|
data : Data set for filling.
|
80
|
-
|
81
|
-
- `None`: Use attribute `Database.
|
80
|
+
echo : Whether report SQL execute information.
|
81
|
+
- `None`: Use attribute `Database.echo`.
|
82
82
|
- `bool`: Use this value.
|
83
83
|
kwdata : Keyword parameters for filling.
|
84
84
|
|
@@ -87,8 +87,8 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
87
87
|
Parameter `sql` and `data` and `report`.
|
88
88
|
"""
|
89
89
|
|
90
|
-
#
|
91
|
-
|
90
|
+
# Set parameter.
|
91
|
+
echo = get_first_notnone(echo, self.conn.db.echo)
|
92
92
|
sql = handle_sql(sql)
|
93
93
|
if data is None:
|
94
94
|
if kwdata == {}:
|
@@ -102,7 +102,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
|
|
102
102
|
row.update(kwdata)
|
103
103
|
data = handle_data(data, sql)
|
104
104
|
|
105
|
-
return sql, data,
|
105
|
+
return sql, data, echo
|
106
106
|
|
107
107
|
|
108
108
|
def handle_select(
|
@@ -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:
|
@@ -638,7 +638,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
638
638
|
self,
|
639
639
|
sql: str | TextClause,
|
640
640
|
data: TableData | None = None,
|
641
|
-
|
641
|
+
echo: bool | None = None,
|
642
642
|
**kwdata: Any
|
643
643
|
) -> Result:
|
644
644
|
"""
|
@@ -648,8 +648,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
648
648
|
----------
|
649
649
|
sql : SQL in method `sqlalchemy.text` format, or `TextClause` object.
|
650
650
|
data : Data set for filling.
|
651
|
-
|
652
|
-
- `None`: Use attribute `Database.
|
651
|
+
echo : Whether report SQL execute information.
|
652
|
+
- `None`: Use attribute `Database.echo`.
|
653
653
|
- `bool`: Use this value.
|
654
654
|
kwdata : Keyword parameters for filling.
|
655
655
|
|
@@ -658,8 +658,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
658
658
|
Result object.
|
659
659
|
"""
|
660
660
|
|
661
|
-
#
|
662
|
-
sql, data,
|
661
|
+
# Set parameter.
|
662
|
+
sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
|
663
663
|
|
664
664
|
# Transaction.
|
665
665
|
self.conn.get_begin()
|
@@ -667,7 +667,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
667
667
|
# Execute.
|
668
668
|
|
669
669
|
## Report.
|
670
|
-
if
|
670
|
+
if echo:
|
671
671
|
execute = wrap_runtime(self.conn.connection.execute, to_return=True, to_print=False)
|
672
672
|
result, report_runtime, *_ = execute(sql, data)
|
673
673
|
report_info = (
|
@@ -680,9 +680,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
680
680
|
if sql_part != ''
|
681
681
|
]
|
682
682
|
if data == []:
|
683
|
-
|
683
|
+
recho(report_info, *sqls, title='SQL')
|
684
684
|
else:
|
685
|
-
|
685
|
+
recho(report_info, *sqls, data, title='SQL')
|
686
686
|
|
687
687
|
## Not report.
|
688
688
|
else:
|
@@ -708,7 +708,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
708
708
|
having: str | None = None,
|
709
709
|
order: str | None = None,
|
710
710
|
limit: int | str | tuple[int, int] | None = None,
|
711
|
-
|
711
|
+
echo: bool | None = None,
|
712
712
|
**kwdata: Any
|
713
713
|
) -> Result:
|
714
714
|
"""
|
@@ -732,8 +732,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
732
732
|
limit : Clause `LIMIT` content.
|
733
733
|
- `int | str`: Join as `LIMIT int/str`.
|
734
734
|
- `tuple[int, int]`: Join as `LIMIT int, int`.
|
735
|
-
|
736
|
-
- `None`: Use attribute `Database.
|
735
|
+
echo : Whether report SQL execute information.
|
736
|
+
- `None`: Use attribute `Database.echo`.
|
737
737
|
kwdata : Keyword parameters for filling.
|
738
738
|
|
739
739
|
Returns
|
@@ -755,11 +755,11 @@ 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.
|
762
|
-
result = self.execute(sql,
|
762
|
+
result = self.execute(sql, echo=echo, **kwdata)
|
763
763
|
|
764
764
|
return result
|
765
765
|
|
@@ -769,7 +769,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
769
769
|
path: str | tuple[str, str],
|
770
770
|
data: TableData,
|
771
771
|
duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
|
772
|
-
|
772
|
+
echo: bool | None = None,
|
773
773
|
**kwdata: Any
|
774
774
|
) -> Result:
|
775
775
|
"""
|
@@ -786,8 +786,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
786
786
|
- `ignore`: Use `UPDATE IGNORE INTO` clause.
|
787
787
|
- `update`: Use `ON DUPLICATE KEY UPDATE` clause and update all fields.
|
788
788
|
- `Container[str]`: Use `ON DUPLICATE KEY UPDATE` clause and update this fields.
|
789
|
-
|
790
|
-
- `None`: Use attribute `Database.
|
789
|
+
echo : Whether report SQL execute information.
|
790
|
+
- `None`: Use attribute `Database.echo`.
|
791
791
|
kwdata : Keyword parameters for filling.
|
792
792
|
- `str and first character is ':'`: Use this syntax.
|
793
793
|
- `Any`: Use this value.
|
@@ -808,11 +808,11 @@ 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.
|
815
|
-
result = self.execute(sql, data,
|
815
|
+
result = self.execute(sql, data, echo, **kwdata)
|
816
816
|
|
817
817
|
return result
|
818
818
|
|
@@ -822,7 +822,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
822
822
|
path: str | tuple[str, str],
|
823
823
|
data: TableData,
|
824
824
|
where_fields: str | Iterable[str] | None = None,
|
825
|
-
|
825
|
+
echo: bool | None = None,
|
826
826
|
**kwdata: Any
|
827
827
|
) -> Result:
|
828
828
|
"""
|
@@ -845,8 +845,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
845
845
|
- `None`: The first key value pair of each item is judged.
|
846
846
|
- `str`: This key value pair of each item is judged.
|
847
847
|
- `Iterable[str]`: Multiple judged, `and`: relationship.
|
848
|
-
|
849
|
-
- `None`: Use attribute `Database.
|
848
|
+
echo : Whether report SQL execute information.
|
849
|
+
- `None`: Use attribute `Database.echo`.
|
850
850
|
kwdata : Keyword parameters for filling.
|
851
851
|
- `str and first character is ':'`: Use this syntax.
|
852
852
|
- `Any`: Use this value.
|
@@ -867,11 +867,11 @@ 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.
|
874
|
-
result = self.execute(sql, data,
|
874
|
+
result = self.execute(sql, data, echo)
|
875
875
|
|
876
876
|
return result
|
877
877
|
|
@@ -882,7 +882,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
882
882
|
where: str | None = None,
|
883
883
|
order: str | None = None,
|
884
884
|
limit: int | str | None = None,
|
885
|
-
|
885
|
+
echo: bool | None = None,
|
886
886
|
**kwdata: Any
|
887
887
|
) -> Result:
|
888
888
|
"""
|
@@ -896,8 +896,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
896
896
|
where : Clause `WHERE` content, join as `WHERE str`.
|
897
897
|
order : Clause `ORDER BY` content, join as `ORDER BY str`.
|
898
898
|
limit : Clause `LIMIT` content, join as `LIMIT int/str`.
|
899
|
-
|
900
|
-
- `None`: Use attribute `Database.
|
899
|
+
echo : Whether report SQL execute information.
|
900
|
+
- `None`: Use attribute `Database.echo`.
|
901
901
|
kwdata : Keyword parameters for filling.
|
902
902
|
|
903
903
|
Returns
|
@@ -913,11 +913,11 @@ 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.
|
920
|
-
result = self.execute(sql,
|
920
|
+
result = self.execute(sql, echo=echo, **kwdata)
|
921
921
|
|
922
922
|
return result
|
923
923
|
|
@@ -928,7 +928,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
928
928
|
fields: str | Iterable[str] | None = None,
|
929
929
|
where: str | None = None,
|
930
930
|
limit: int | str | tuple[int, int] | None = None,
|
931
|
-
|
931
|
+
echo: bool | None = None,
|
932
932
|
**kwdata: Any
|
933
933
|
) -> Result:
|
934
934
|
"""
|
@@ -947,6 +947,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
947
947
|
limit : Clause `LIMIT` content.
|
948
948
|
- `int | str`: Join as `LIMIT int/str`.
|
949
949
|
- `tuple[int, int]`: Join as `LIMIT int, int`.
|
950
|
+
echo : Whether report SQL execute information.
|
951
|
+
- `None`: Use attribute `Database.echo`.
|
950
952
|
kwdata : Keyword parameters for filling.
|
951
953
|
|
952
954
|
Returns
|
@@ -962,11 +964,11 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
962
964
|
2
|
963
965
|
"""
|
964
966
|
|
965
|
-
#
|
967
|
+
# Set parameter.
|
966
968
|
sql = self.handle_copy(path, fields, where, limit)
|
967
969
|
|
968
970
|
# Execute SQL.
|
969
|
-
result = self.execute(sql,
|
971
|
+
result = self.execute(sql, echo=echo, **kwdata)
|
970
972
|
|
971
973
|
return result
|
972
974
|
|
@@ -975,7 +977,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
975
977
|
self,
|
976
978
|
path: str | tuple[str, str],
|
977
979
|
where: str | None = None,
|
978
|
-
|
980
|
+
echo: bool | None = None,
|
979
981
|
**kwdata: Any
|
980
982
|
) -> int:
|
981
983
|
"""
|
@@ -989,8 +991,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
989
991
|
where : Match condition, `WHERE` clause content, join as `WHERE str`.
|
990
992
|
- `None`: Match all.
|
991
993
|
- `str`: Match condition.
|
992
|
-
|
993
|
-
- `None`: Use attribute `Database.
|
994
|
+
echo : Whether report SQL execute information.
|
995
|
+
- `None`: Use attribute `Database.echo`.
|
994
996
|
kwdata : Keyword parameters for filling.
|
995
997
|
|
996
998
|
Returns
|
@@ -1007,7 +1009,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1007
1009
|
"""
|
1008
1010
|
|
1009
1011
|
# Execute.
|
1010
|
-
result = self.select(path, '1', where=where,
|
1012
|
+
result = self.select(path, '1', where=where, echo=echo, **kwdata)
|
1011
1013
|
count = len(tuple(result))
|
1012
1014
|
|
1013
1015
|
return count
|
@@ -1017,7 +1019,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1017
1019
|
self,
|
1018
1020
|
path: str | tuple[str, str],
|
1019
1021
|
where: str | None = None,
|
1020
|
-
|
1022
|
+
echo: bool | None = None,
|
1021
1023
|
**kwdata: Any
|
1022
1024
|
) -> bool:
|
1023
1025
|
"""
|
@@ -1031,8 +1033,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1031
1033
|
where : Match condition, `WHERE` clause content, join as `WHERE str`.
|
1032
1034
|
- `None`: Match all.
|
1033
1035
|
- `str`: Match condition.
|
1034
|
-
|
1035
|
-
- `None`: Use attribute `Database.
|
1036
|
+
echo : Whether report SQL execute information.
|
1037
|
+
- `None`: Use attribute `Database.echo`.
|
1036
1038
|
kwdata : Keyword parameters for filling.
|
1037
1039
|
|
1038
1040
|
Returns
|
@@ -1051,7 +1053,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1051
1053
|
"""
|
1052
1054
|
|
1053
1055
|
# Execute.
|
1054
|
-
result = self.count(path, where,
|
1056
|
+
result = self.count(path, where, echo, **kwdata)
|
1055
1057
|
|
1056
1058
|
# Judge.
|
1057
1059
|
judge = result != 0
|
@@ -1063,7 +1065,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1063
1065
|
self,
|
1064
1066
|
sql: str | TextClause,
|
1065
1067
|
data: TableData,
|
1066
|
-
|
1068
|
+
echo: bool | None = None,
|
1067
1069
|
**kwdata: Any
|
1068
1070
|
) -> Generator[Result, Any, None]:
|
1069
1071
|
"""
|
@@ -1073,8 +1075,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1073
1075
|
----------
|
1074
1076
|
sql : SQL in method `sqlalchemy.text` format, or `TextClause` object.
|
1075
1077
|
data : Data set for filling.
|
1076
|
-
|
1077
|
-
- `None`: Use attribute `Database.
|
1078
|
+
echo : Whether report SQL execute information.
|
1079
|
+
- `None`: Use attribute `Database.echo`.
|
1078
1080
|
- `bool`: Use this value.
|
1079
1081
|
kwdata : Keyword parameters for filling.
|
1080
1082
|
|
@@ -1087,7 +1089,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1087
1089
|
func_generator = FunctionGenerator(
|
1088
1090
|
self.execute,
|
1089
1091
|
sql=sql,
|
1090
|
-
|
1092
|
+
echo=echo,
|
1091
1093
|
**kwdata
|
1092
1094
|
)
|
1093
1095
|
|
@@ -1102,24 +1104,24 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1102
1104
|
|
1103
1105
|
|
1104
1106
|
@overload
|
1105
|
-
def sleep(self,
|
1107
|
+
def sleep(self, echo: bool | None = None) -> int: ...
|
1106
1108
|
|
1107
1109
|
@overload
|
1108
|
-
def sleep(self, second: int,
|
1110
|
+
def sleep(self, second: int, echo: bool | None = None) -> int: ...
|
1109
1111
|
|
1110
1112
|
@overload
|
1111
|
-
def sleep(self, low: int = 0, high: int = 10,
|
1113
|
+
def sleep(self, low: int = 0, high: int = 10, echo: bool | None = None) -> int: ...
|
1112
1114
|
|
1113
1115
|
@overload
|
1114
|
-
def sleep(self, *thresholds: float,
|
1116
|
+
def sleep(self, *thresholds: float, echo: bool | None = None) -> float: ...
|
1115
1117
|
|
1116
1118
|
@overload
|
1117
|
-
def sleep(self, *thresholds: float, precision: Literal[0],
|
1119
|
+
def sleep(self, *thresholds: float, precision: Literal[0], echo: bool | None = None) -> int: ...
|
1118
1120
|
|
1119
1121
|
@overload
|
1120
|
-
def sleep(self, *thresholds: float, precision: int,
|
1122
|
+
def sleep(self, *thresholds: float, precision: int, echo: bool | None = None) -> float: ...
|
1121
1123
|
|
1122
|
-
def sleep(self, *thresholds: float, precision: int | None = None,
|
1124
|
+
def sleep(self, *thresholds: float, precision: int | None = None, echo: bool | None = None) -> float:
|
1123
1125
|
"""
|
1124
1126
|
Let the database wait random seconds.
|
1125
1127
|
|
@@ -1132,8 +1134,8 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1132
1134
|
precision : Precision of random range, that is maximum decimal digits of return value.
|
1133
1135
|
- `None`: Set to Maximum decimal digits of element of parameter `thresholds`.
|
1134
1136
|
- `int`: Set to this value.
|
1135
|
-
|
1136
|
-
- `None`: Use attribute `Database.
|
1137
|
+
echo : Whether report SQL execute information.
|
1138
|
+
- `None`: Use attribute `Database.echo`.
|
1137
1139
|
- `bool`: Use this value.
|
1138
1140
|
|
1139
1141
|
Returns
|
@@ -1143,7 +1145,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1143
1145
|
- When parameters `precision` is `greater than 0`, then return float.
|
1144
1146
|
"""
|
1145
1147
|
|
1146
|
-
#
|
1148
|
+
# Set parameter.
|
1147
1149
|
if len(thresholds) == 1:
|
1148
1150
|
second = thresholds[0]
|
1149
1151
|
else:
|
@@ -1151,7 +1153,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
|
|
1151
1153
|
|
1152
1154
|
# Sleep.
|
1153
1155
|
sql = f'SELECT SLEEP({second})'
|
1154
|
-
self.execute(sql,
|
1156
|
+
self.execute(sql, echo=echo)
|
1155
1157
|
|
1156
1158
|
return second
|
1157
1159
|
|
@@ -1166,7 +1168,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1166
1168
|
self,
|
1167
1169
|
sql: str | TextClause,
|
1168
1170
|
data: TableData | None = None,
|
1169
|
-
|
1171
|
+
echo: bool | None = None,
|
1170
1172
|
**kwdata: Any
|
1171
1173
|
) -> Result:
|
1172
1174
|
"""
|
@@ -1176,9 +1178,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1176
1178
|
----------
|
1177
1179
|
sql : SQL in method `sqlalchemy.text` format, or `TextClause` object.
|
1178
1180
|
data : Data set for filling.
|
1179
|
-
|
1180
|
-
- `None`: Use attribute `
|
1181
|
-
- `bool`: Use this value.
|
1181
|
+
echo : Whether report SQL execute information.
|
1182
|
+
- `None`: Use attribute `Database.echo`.
|
1182
1183
|
kwdata : Keyword parameters for filling.
|
1183
1184
|
|
1184
1185
|
Returns
|
@@ -1186,8 +1187,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1186
1187
|
Result object.
|
1187
1188
|
"""
|
1188
1189
|
|
1189
|
-
#
|
1190
|
-
sql, data,
|
1190
|
+
# Set parameter.
|
1191
|
+
sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
|
1191
1192
|
|
1192
1193
|
# Transaction.
|
1193
1194
|
await self.conn.get_begin()
|
@@ -1195,7 +1196,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1195
1196
|
# Execute.
|
1196
1197
|
|
1197
1198
|
## Report.
|
1198
|
-
if
|
1199
|
+
if echo:
|
1199
1200
|
tm = TimeMark()
|
1200
1201
|
tm()
|
1201
1202
|
result = await self.conn.connection.execute(sql, data)
|
@@ -1224,9 +1225,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1224
1225
|
]
|
1225
1226
|
|
1226
1227
|
if data == []:
|
1227
|
-
|
1228
|
+
recho(report_info, *sqls, title='SQL')
|
1228
1229
|
else:
|
1229
|
-
|
1230
|
+
recho(report_info, *sqls, data, title='SQL')
|
1230
1231
|
|
1231
1232
|
## Not report.
|
1232
1233
|
else:
|
@@ -1253,7 +1254,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1253
1254
|
having: str | None = None,
|
1254
1255
|
order: str | None = None,
|
1255
1256
|
limit: int | str | tuple[int, int] | None = None,
|
1256
|
-
|
1257
|
+
echo: bool | None = None,
|
1257
1258
|
**kwdata: Any
|
1258
1259
|
) -> Result:
|
1259
1260
|
"""
|
@@ -1277,8 +1278,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1277
1278
|
limit : Clause `LIMIT` content.
|
1278
1279
|
- `int | str`: Join as `LIMIT int/str`.
|
1279
1280
|
- `tuple[int, int]`: Join as `LIMIT int, int`.
|
1280
|
-
|
1281
|
-
- `None`: Use attribute `Database.
|
1281
|
+
echo : Whether report SQL execute information.
|
1282
|
+
- `None`: Use attribute `Database.echo`.
|
1282
1283
|
kwdata : Keyword parameters for filling.
|
1283
1284
|
|
1284
1285
|
Returns
|
@@ -1300,11 +1301,11 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1300
1301
|
[{'id': 1, 'id_': 2}, ...]
|
1301
1302
|
"""
|
1302
1303
|
|
1303
|
-
#
|
1304
|
+
# Set parameter.
|
1304
1305
|
sql = self.handle_select(path, fields, where, group, having, order, limit)
|
1305
1306
|
|
1306
1307
|
# Execute SQL.
|
1307
|
-
result = await self.execute(sql,
|
1308
|
+
result = await self.execute(sql, echo=echo, **kwdata)
|
1308
1309
|
|
1309
1310
|
return result
|
1310
1311
|
|
@@ -1314,7 +1315,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1314
1315
|
path: str | tuple[str, str],
|
1315
1316
|
data: TableData,
|
1316
1317
|
duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
|
1317
|
-
|
1318
|
+
echo: bool | None = None,
|
1318
1319
|
**kwdata: Any
|
1319
1320
|
) -> Result:
|
1320
1321
|
"""
|
@@ -1331,8 +1332,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1331
1332
|
- `ignore`: Use `UPDATE IGNORE INTO` clause.
|
1332
1333
|
- `update`: Use `ON DUPLICATE KEY UPDATE` clause and update all fields.
|
1333
1334
|
- `Container[str]`: Use `ON DUPLICATE KEY UPDATE` clause and update this fields.
|
1334
|
-
|
1335
|
-
- `None`: Use attribute `Database.
|
1335
|
+
echo : Whether report SQL execute information.
|
1336
|
+
- `None`: Use attribute `Database.echo`.
|
1336
1337
|
kwdata : Keyword parameters for filling.
|
1337
1338
|
- `str and first character is ':'`: Use this syntax.
|
1338
1339
|
- `Any`: Use this value.
|
@@ -1353,11 +1354,11 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1353
1354
|
[{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
|
1354
1355
|
"""
|
1355
1356
|
|
1356
|
-
#
|
1357
|
+
# Set parameter.
|
1357
1358
|
sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
|
1358
1359
|
|
1359
1360
|
# Execute SQL.
|
1360
|
-
result = await self.execute(sql, data,
|
1361
|
+
result = await self.execute(sql, data, echo, **kwdata)
|
1361
1362
|
|
1362
1363
|
return result
|
1363
1364
|
|
@@ -1367,7 +1368,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1367
1368
|
path: str | tuple[str, str],
|
1368
1369
|
data: TableData,
|
1369
1370
|
where_fields: str | Iterable[str] | None = None,
|
1370
|
-
|
1371
|
+
echo: bool | None = None,
|
1371
1372
|
**kwdata: Any
|
1372
1373
|
) -> Result:
|
1373
1374
|
"""
|
@@ -1390,8 +1391,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1390
1391
|
- `None`: The first key value pair of each item is judged.
|
1391
1392
|
- `str`: This key value pair of each item is judged.
|
1392
1393
|
- `Iterable[str]`: Multiple judged, `and`: relationship.
|
1393
|
-
|
1394
|
-
- `None`: Use attribute `Database.
|
1394
|
+
echo : Whether report SQL execute information.
|
1395
|
+
- `None`: Use attribute `Database.echo`.
|
1395
1396
|
kwdata : Keyword parameters for filling.
|
1396
1397
|
- `str and first character is ':'`: Use this syntax.
|
1397
1398
|
- `Any`: Use this value.
|
@@ -1412,11 +1413,11 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1412
1413
|
[{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
|
1413
1414
|
"""
|
1414
1415
|
|
1415
|
-
#
|
1416
|
+
# Set parameter.
|
1416
1417
|
sql, data = self.handle_update(path, data, where_fields, **kwdata)
|
1417
1418
|
|
1418
1419
|
# Execute SQL.
|
1419
|
-
result = await self.execute(sql, data,
|
1420
|
+
result = await self.execute(sql, data, echo)
|
1420
1421
|
|
1421
1422
|
return result
|
1422
1423
|
|
@@ -1427,7 +1428,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1427
1428
|
where: str | None = None,
|
1428
1429
|
order: str | None = None,
|
1429
1430
|
limit: int | str | None = None,
|
1430
|
-
|
1431
|
+
echo: bool | None = None,
|
1431
1432
|
**kwdata: Any
|
1432
1433
|
) -> Result:
|
1433
1434
|
"""
|
@@ -1441,8 +1442,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1441
1442
|
where : Clause `WHERE` content, join as `WHERE str`.
|
1442
1443
|
order : Clause `ORDER BY` content, join as `ORDER BY str`.
|
1443
1444
|
limit : Clause `LIMIT` content, join as `LIMIT int/str`.
|
1444
|
-
|
1445
|
-
- `None`: Use attribute `Database.
|
1445
|
+
echo : Whether report SQL execute information.
|
1446
|
+
- `None`: Use attribute `Database.echo`.
|
1446
1447
|
kwdata : Keyword parameters for filling.
|
1447
1448
|
|
1448
1449
|
Returns
|
@@ -1458,11 +1459,11 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1458
1459
|
2
|
1459
1460
|
"""
|
1460
1461
|
|
1461
|
-
#
|
1462
|
+
# Set parameter.
|
1462
1463
|
sql = self.handle_delete(path, where, order, limit)
|
1463
1464
|
|
1464
1465
|
# Execute SQL.
|
1465
|
-
result = await self.execute(sql,
|
1466
|
+
result = await self.execute(sql, echo=echo, **kwdata)
|
1466
1467
|
|
1467
1468
|
return result
|
1468
1469
|
|
@@ -1473,7 +1474,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1473
1474
|
fields: str | Iterable[str] | None = None,
|
1474
1475
|
where: str | None = None,
|
1475
1476
|
limit: int | str | tuple[int, int] | None = None,
|
1476
|
-
|
1477
|
+
echo: bool | None = None,
|
1477
1478
|
**kwdata: Any
|
1478
1479
|
) -> Result:
|
1479
1480
|
"""
|
@@ -1492,6 +1493,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1492
1493
|
limit : Clause `LIMIT` content.
|
1493
1494
|
- `int | str`: Join as `LIMIT int/str`.
|
1494
1495
|
- `tuple[int, int]`: Join as `LIMIT int, int`.
|
1496
|
+
echo : Whether report SQL execute information.
|
1497
|
+
- `None`: Use attribute `Database.echo`.
|
1495
1498
|
kwdata : Keyword parameters for filling.
|
1496
1499
|
|
1497
1500
|
Returns
|
@@ -1507,11 +1510,11 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1507
1510
|
2
|
1508
1511
|
"""
|
1509
1512
|
|
1510
|
-
#
|
1513
|
+
# Set parameter.
|
1511
1514
|
sql = self.handle_copy(path, fields, where, limit)
|
1512
1515
|
|
1513
1516
|
# Execute SQL.
|
1514
|
-
result = await self.execute(sql,
|
1517
|
+
result = await self.execute(sql, echo=echo, **kwdata)
|
1515
1518
|
|
1516
1519
|
return result
|
1517
1520
|
|
@@ -1520,7 +1523,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1520
1523
|
self,
|
1521
1524
|
path: str | tuple[str, str],
|
1522
1525
|
where: str | None = None,
|
1523
|
-
|
1526
|
+
echo: bool | None = None,
|
1524
1527
|
**kwdata: Any
|
1525
1528
|
) -> int:
|
1526
1529
|
"""
|
@@ -1534,8 +1537,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1534
1537
|
where : Match condition, `WHERE` clause content, join as `WHERE str`.
|
1535
1538
|
- `None`: Match all.
|
1536
1539
|
- `str`: Match condition.
|
1537
|
-
|
1538
|
-
- `None`: Use attribute `Database.
|
1540
|
+
echo : Whether report SQL execute information.
|
1541
|
+
- `None`: Use attribute `Database.echo`.
|
1539
1542
|
kwdata : Keyword parameters for filling.
|
1540
1543
|
|
1541
1544
|
Returns
|
@@ -1552,7 +1555,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1552
1555
|
"""
|
1553
1556
|
|
1554
1557
|
# Execute.
|
1555
|
-
result = await self.select(path, '1', where=where,
|
1558
|
+
result = await self.select(path, '1', where=where, echo=echo, **kwdata)
|
1556
1559
|
count = len(tuple(result))
|
1557
1560
|
|
1558
1561
|
return count
|
@@ -1562,7 +1565,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1562
1565
|
self,
|
1563
1566
|
path: str | tuple[str, str],
|
1564
1567
|
where: str | None = None,
|
1565
|
-
|
1568
|
+
echo: bool | None = None,
|
1566
1569
|
**kwdata: Any
|
1567
1570
|
) -> bool:
|
1568
1571
|
"""
|
@@ -1576,8 +1579,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1576
1579
|
where : Match condition, `WHERE` clause content, join as `WHERE str`.
|
1577
1580
|
- `None`: Match all.
|
1578
1581
|
- `str`: Match condition.
|
1579
|
-
|
1580
|
-
- `None`: Use attribute `Database.
|
1582
|
+
echo : Whether report SQL execute information.
|
1583
|
+
- `None`: Use attribute `Database.echo`.
|
1581
1584
|
kwdata : Keyword parameters for filling.
|
1582
1585
|
|
1583
1586
|
Returns
|
@@ -1596,7 +1599,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1596
1599
|
"""
|
1597
1600
|
|
1598
1601
|
# Execute.
|
1599
|
-
result = await self.count(path, where,
|
1602
|
+
result = await self.count(path, where, echo, **kwdata)
|
1600
1603
|
|
1601
1604
|
# Judge.
|
1602
1605
|
judge = result != 0
|
@@ -1608,7 +1611,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1608
1611
|
self,
|
1609
1612
|
sql: str | TextClause,
|
1610
1613
|
data: TableData,
|
1611
|
-
|
1614
|
+
echo: bool | None = None,
|
1612
1615
|
**kwdata: Any
|
1613
1616
|
) -> AsyncGenerator[Result, Any]:
|
1614
1617
|
"""
|
@@ -1618,9 +1621,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1618
1621
|
----------
|
1619
1622
|
sql : SQL in method `sqlalchemy.text` format, or `TextClause` object.
|
1620
1623
|
data : Data set for filling.
|
1621
|
-
|
1622
|
-
- `None`: Use attribute `
|
1623
|
-
- `bool`: Use this value.
|
1624
|
+
echo : Whether report SQL execute information.
|
1625
|
+
- `None`: Use attribute `Database.echo`.
|
1624
1626
|
kwdata : Keyword parameters for filling.
|
1625
1627
|
|
1626
1628
|
Returns
|
@@ -1632,7 +1634,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1632
1634
|
func_generator = FunctionGenerator(
|
1633
1635
|
self.execute,
|
1634
1636
|
sql=sql,
|
1635
|
-
|
1637
|
+
echo=echo,
|
1636
1638
|
**kwdata
|
1637
1639
|
)
|
1638
1640
|
|
@@ -1647,24 +1649,24 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1647
1649
|
|
1648
1650
|
|
1649
1651
|
@overload
|
1650
|
-
async def sleep(self,
|
1652
|
+
async def sleep(self, echo: bool | None = None) -> int: ...
|
1651
1653
|
|
1652
1654
|
@overload
|
1653
|
-
async def sleep(self, second: int,
|
1655
|
+
async def sleep(self, second: int, echo: bool | None = None) -> int: ...
|
1654
1656
|
|
1655
1657
|
@overload
|
1656
|
-
async def sleep(self, low: int = 0, high: int = 10,
|
1658
|
+
async def sleep(self, low: int = 0, high: int = 10, echo: bool | None = None) -> int: ...
|
1657
1659
|
|
1658
1660
|
@overload
|
1659
|
-
async def sleep(self, *thresholds: float,
|
1661
|
+
async def sleep(self, *thresholds: float, echo: bool | None = None) -> float: ...
|
1660
1662
|
|
1661
1663
|
@overload
|
1662
|
-
async def sleep(self, *thresholds: float, precision: Literal[0],
|
1664
|
+
async def sleep(self, *thresholds: float, precision: Literal[0], echo: bool | None = None) -> int: ...
|
1663
1665
|
|
1664
1666
|
@overload
|
1665
|
-
async def sleep(self, *thresholds: float, precision: int,
|
1667
|
+
async def sleep(self, *thresholds: float, precision: int, echo: bool | None = None) -> float: ...
|
1666
1668
|
|
1667
|
-
async def sleep(self, *thresholds: float, precision: int | None = None,
|
1669
|
+
async def sleep(self, *thresholds: float, precision: int | None = None, echo: bool | None = None) -> float:
|
1668
1670
|
"""
|
1669
1671
|
Asynchronous let the database wait random seconds.
|
1670
1672
|
|
@@ -1677,9 +1679,8 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1677
1679
|
precision : Precision of random range, that is maximum decimal digits of return value.
|
1678
1680
|
- `None`: Set to Maximum decimal digits of element of parameter `thresholds`.
|
1679
1681
|
- `int`: Set to this value.
|
1680
|
-
|
1681
|
-
- `None`: Use attribute `
|
1682
|
-
- `bool`: Use this value.
|
1682
|
+
echo : Whether report SQL execute information.
|
1683
|
+
- `None`: Use attribute `Database.echo`.
|
1683
1684
|
|
1684
1685
|
Returns
|
1685
1686
|
-------
|
@@ -1688,7 +1689,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1688
1689
|
- When parameters `precision` is `greater than 0`, then return float.
|
1689
1690
|
"""
|
1690
1691
|
|
1691
|
-
#
|
1692
|
+
# Set parameter.
|
1692
1693
|
if len(thresholds) == 1:
|
1693
1694
|
second = thresholds[0]
|
1694
1695
|
else:
|
@@ -1696,6 +1697,6 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
|
|
1696
1697
|
|
1697
1698
|
# Sleep.
|
1698
1699
|
sql = f'SELECT SLEEP({second})'
|
1699
|
-
await self.execute(sql,
|
1700
|
+
await self.execute(sql, echo=echo)
|
1700
1701
|
|
1701
1702
|
return second
|