reydb 1.1.61__py3-none-any.whl → 1.2.0__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/rexec.py CHANGED
@@ -24,7 +24,7 @@ from reykit.rtime import TimeMark, time_to
24
24
  from reykit.rwrap import wrap_runtime
25
25
 
26
26
  from . import rconn
27
- from .rbase import DatabaseBase, handle_sql, handle_data, extract_path
27
+ from .rbase import DatabaseBase, handle_sql, handle_data
28
28
 
29
29
 
30
30
  __all__ = (
@@ -71,7 +71,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
71
71
  **kwdata: Any
72
72
  ) -> tuple[TextClause, list[dict], bool]:
73
73
  """
74
- Handle parameters before execute SQL.
74
+ Handle method of execute SQL.
75
75
 
76
76
  Parameters
77
77
  ----------
@@ -107,7 +107,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
107
107
 
108
108
  def handle_select(
109
109
  self,
110
- table: str,
110
+ path: str | tuple[str, str],
111
111
  fields: str | Iterable[str] | None = None,
112
112
  where: str | None = None,
113
113
  group: str | None = None,
@@ -116,11 +116,13 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
116
116
  limit: int | str | tuple[int, int] | None = None
117
117
  ) -> str:
118
118
  """
119
- Handle parameters before execute select SQL.
119
+ Handle method of execute select SQL.
120
120
 
121
121
  Parameters
122
122
  ----------
123
- table : Table name, can include database name.
123
+ path : Path.
124
+ - `str`: Table name.
125
+ - `tuple[str, str]`: Database name and table name.
124
126
  fields : Select clause content.
125
127
  - `None`: Is `SELECT *`.
126
128
  - `str`: Join as `SELECT str`.
@@ -141,9 +143,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
141
143
  """
142
144
 
143
145
  # Handle parameter.
144
- database = self.conn.db.database
145
- if '.' in table:
146
- database, table, _ = extract_path(table)
146
+ if type(path) == str:
147
+ database, table = self.conn.db.database, path
148
+ else:
149
+ database, table = path
147
150
 
148
151
  # Generate SQL.
149
152
  sql_list = []
@@ -209,17 +212,19 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
209
212
 
210
213
  def handle_insert(
211
214
  self,
212
- table: str,
215
+ path: str | tuple[str, str],
213
216
  data: TableData,
214
217
  duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
215
218
  **kwdata: Any
216
219
  ) -> Result:
217
220
  """
218
- Handle parameters before execute insert SQL.
221
+ Handle method of execute insert SQL.
219
222
 
220
223
  Parameters
221
224
  ----------
222
- table : Table name, can include database name.
225
+ path : Path.
226
+ - `str`: Table name.
227
+ - `tuple[str, str]`: Database name and table name.
223
228
  data : Insert data.
224
229
  duplicate : Handle method when constraint error.
225
230
  - `None`: Not handled.
@@ -236,9 +241,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
236
241
  """
237
242
 
238
243
  # Handle parameter.
239
- database = self.conn.db.database
240
- if '.' in table:
241
- database, table, _ = extract_path(table)
244
+ if type(path) == str:
245
+ database, table = self.conn.db.database, path
246
+ else:
247
+ database, table = path
242
248
 
243
249
  ## Data.
244
250
  data_table = Table(data)
@@ -343,7 +349,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
343
349
 
344
350
  def handle_update(
345
351
  self,
346
- table: str,
352
+ path: str | tuple[str, str],
347
353
  data: TableData,
348
354
  where_fields: str | Iterable[str] | None = None,
349
355
  **kwdata: Any
@@ -353,7 +359,9 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
353
359
 
354
360
  Parameters
355
361
  ----------
356
- table : Table name, can include database name.
362
+ path : Path.
363
+ - `str`: Table name.
364
+ - `tuple[str, str]`: Database name and table name.
357
365
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
358
366
  - `Key`: Table field.
359
367
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -376,9 +384,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
376
384
  """
377
385
 
378
386
  # Handle parameter.
379
- database = self.conn.db.database
380
- if '.' in table:
381
- database, table, _ = extract_path(table)
387
+ if type(path) == str:
388
+ database, table = self.conn.db.database, path
389
+ else:
390
+ database, table = path
382
391
 
383
392
  ## Data.
384
393
  data_table = Table(data)
@@ -486,7 +495,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
486
495
 
487
496
  def handle_delete(
488
497
  self,
489
- table: str,
498
+ path: str | tuple[str, str],
490
499
  where: str | None = None,
491
500
  order: str | None = None,
492
501
  limit: int | str | None = None
@@ -496,7 +505,9 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
496
505
 
497
506
  Parameters
498
507
  ----------
499
- table : Table name, can include database name.
508
+ path : Path.
509
+ - `str`: Table name.
510
+ - `tuple[str, str]`: Database name and table name.
500
511
  where : Clause `WHERE` content, join as `WHERE str`.
501
512
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
502
513
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -507,9 +518,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
507
518
  """
508
519
 
509
520
  # Handle parameter.
510
- database = self.conn.db.database
511
- if '.' in table:
512
- database, table, _ = extract_path(table)
521
+ if type(path) == str:
522
+ database, table = self.conn.db.database, path
523
+ else:
524
+ database, table = path
513
525
 
514
526
  # Generate SQL.
515
527
  sqls = []
@@ -541,7 +553,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
541
553
 
542
554
  def handle_copy(
543
555
  self,
544
- table: str,
556
+ path: str | tuple[str, str],
545
557
  fields: str | Iterable[str] | None = None,
546
558
  where: str | None = None,
547
559
  limit: int | str | tuple[int, int] | None = None
@@ -551,7 +563,9 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
551
563
 
552
564
  Parameters
553
565
  ----------
554
- table : Table name, can include database name.
566
+ path : Path.
567
+ - `str`: Table name.
568
+ - `tuple[str, str]`: Database name and table name.
555
569
  fields : Select clause content.
556
570
  - `None`: Is `SELECT *`.
557
571
  - `str`: Join as `SELECT str`.
@@ -567,9 +581,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
567
581
  """
568
582
 
569
583
  # Handle parameter.
570
- database = self.conn.db.database
571
- if '.' in table:
572
- database, table, _ = extract_path(table)
584
+ if type(path) == str:
585
+ database, table = self.conn.db.database, path
586
+ else:
587
+ database, table = path
573
588
  if fields is None:
574
589
  fields = '*'
575
590
  elif type(fields) != str:
@@ -686,7 +701,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
686
701
 
687
702
  def select(
688
703
  self,
689
- table: str,
704
+ path: str | tuple[str, str],
690
705
  fields: str | Iterable[str] | None = None,
691
706
  where: str | None = None,
692
707
  group: str | None = None,
@@ -701,7 +716,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
701
716
 
702
717
  Parameters
703
718
  ----------
704
- table : Table name, can include database name.
719
+ path : Path.
720
+ - `str`: Table name.
721
+ - `tuple[str, str]`: Database name and table name.
705
722
  fields : Select clause content.
706
723
  - `None`: Is `SELECT *`.
707
724
  - `str`: Join as `SELECT str`.
@@ -739,7 +756,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
739
756
  """
740
757
 
741
758
  # Handle parameter.
742
- sql = self.handle_select(table, fields, where, group, having, order, limit)
759
+ sql = self.handle_select(path, fields, where, group, having, order, limit)
743
760
 
744
761
  # Execute SQL.
745
762
  result = self.execute(sql, report=report, **kwdata)
@@ -749,7 +766,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
749
766
 
750
767
  def insert(
751
768
  self,
752
- table: str,
769
+ path: str | tuple[str, str],
753
770
  data: TableData,
754
771
  duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
755
772
  report: bool | None = None,
@@ -760,7 +777,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
760
777
 
761
778
  Parameters
762
779
  ----------
763
- table : Table name, can include database name.
780
+ path : Path.
781
+ - `str`: Table name.
782
+ - `tuple[str, str]`: Database name and table name.
764
783
  data : Insert data.
765
784
  duplicate : Handle method when constraint error.
766
785
  - `None`: Not handled.
@@ -779,7 +798,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
779
798
 
780
799
  Examples
781
800
  --------
782
- Parameter `data` and `kwdata`.
783
801
  >>> data = [{'key': 'a'}, {'key': 'b'}]
784
802
  >>> kwdata = {'value1': 1, 'value2': ':(SELECT 2)'}
785
803
  >>> result = Database.execute.insert('table', data, **kwdata)
@@ -791,7 +809,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
791
809
  """
792
810
 
793
811
  # Handle parameter.
794
- sql, kwdata = self.handle_insert(table, data, duplicate, **kwdata)
812
+ sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
795
813
 
796
814
  # Execute SQL.
797
815
  result = self.execute(sql, data, report, **kwdata)
@@ -801,7 +819,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
801
819
 
802
820
  def update(
803
821
  self,
804
- table: str,
822
+ path: str | tuple[str, str],
805
823
  data: TableData,
806
824
  where_fields: str | Iterable[str] | None = None,
807
825
  report: bool | None = None,
@@ -812,7 +830,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
812
830
 
813
831
  Parameters
814
832
  ----------
815
- table : Table name, can include database name.
833
+ path : Path.
834
+ - `str`: Table name.
835
+ - `tuple[str, str]`: Database name and table name.
816
836
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
817
837
  - `Key`: Table field.
818
838
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -837,7 +857,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
837
857
 
838
858
  Examples
839
859
  --------
840
- Parameter `data` and `kwdata`.
841
860
  >>> data = [{'key': 'a'}, {'key': 'b'}]
842
861
  >>> kwdata = {'value': 1, 'name': ':`key`'}
843
862
  >>> result = Database.execute.update('table', data, **kwdata)
@@ -849,7 +868,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
849
868
  """
850
869
 
851
870
  # Handle parameter.
852
- sql, data = self.handle_update(table, data, where_fields, **kwdata)
871
+ sql, data = self.handle_update(path, data, where_fields, **kwdata)
853
872
 
854
873
  # Execute SQL.
855
874
  result = self.execute(sql, data, report)
@@ -859,7 +878,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
859
878
 
860
879
  def delete(
861
880
  self,
862
- table: str,
881
+ path: str | tuple[str, str],
863
882
  where: str | None = None,
864
883
  order: str | None = None,
865
884
  limit: int | str | None = None,
@@ -871,7 +890,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
871
890
 
872
891
  Parameters
873
892
  ----------
874
- table : Table name, can include database name.
893
+ path : Path.
894
+ - `str`: Table name.
895
+ - `tuple[str, str]`: Database name and table name.
875
896
  where : Clause `WHERE` content, join as `WHERE str`.
876
897
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
877
898
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -885,7 +906,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
885
906
 
886
907
  Examples
887
908
  --------
888
- Parameter `where` and `kwdata`.
889
909
  >>> where = '`id` IN :ids'
890
910
  >>> ids = (1, 2)
891
911
  >>> result = Database.execute.delete('table', where, ids=ids)
@@ -894,7 +914,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
894
914
  """
895
915
 
896
916
  # Handle parameter.
897
- sql = self.handle_delete(table, where, order, limit)
917
+ sql = self.handle_delete(path, where, order, limit)
898
918
 
899
919
  # Execute SQL.
900
920
  result = self.execute(sql, report=report, **kwdata)
@@ -904,7 +924,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
904
924
 
905
925
  def copy(
906
926
  self,
907
- table: str,
927
+ path: str | tuple[str, str],
908
928
  fields: str | Iterable[str] | None = None,
909
929
  where: str | None = None,
910
930
  limit: int | str | tuple[int, int] | None = None,
@@ -916,7 +936,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
916
936
 
917
937
  Parameters
918
938
  ----------
919
- table : Table name, can include database name.
939
+ path : Path.
940
+ - `str`: Table name.
941
+ - `tuple[str, str]`: Database name and table name.
920
942
  fields : Select clause content.
921
943
  - `None`: Is `SELECT *`.
922
944
  - `str`: Join as `SELECT str`.
@@ -933,7 +955,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
933
955
 
934
956
  Examples
935
957
  --------
936
- Parameter `where` and `kwdata`.
937
958
  >>> where = '`id` IN :ids'
938
959
  >>> ids = (1, 2, 3)
939
960
  >>> result = Database.execute.copy('table', where, 2, ids=ids, id=None, time=':NOW()')
@@ -942,7 +963,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
942
963
  """
943
964
 
944
965
  # Handle parameter.
945
- sql = self.handle_copy(table, fields, where, limit)
966
+ sql = self.handle_copy(path, fields, where, limit)
946
967
 
947
968
  # Execute SQL.
948
969
  result = self.execute(sql, report=report, **kwdata)
@@ -952,7 +973,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
952
973
 
953
974
  def count(
954
975
  self,
955
- table: str,
976
+ path: str | tuple[str, str],
956
977
  where: str | None = None,
957
978
  report: bool | None = None,
958
979
  **kwdata: Any
@@ -962,7 +983,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
962
983
 
963
984
  Parameters
964
985
  ----------
965
- table : Table name, can include database name.
986
+ path : Path.
987
+ - `str`: Table name.
988
+ - `tuple[str, str]`: Database name and table name.
966
989
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
967
990
  - `None`: Match all.
968
991
  - `str`: Match condition.
@@ -976,7 +999,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
976
999
 
977
1000
  Examples
978
1001
  --------
979
- Parameter `where` and `kwdata`.
980
1002
  >>> where = '`id` IN :ids'
981
1003
  >>> ids = (1, 2)
982
1004
  >>> result = Database.execute.count('table', where, ids=ids)
@@ -985,7 +1007,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
985
1007
  """
986
1008
 
987
1009
  # Execute.
988
- result = self.select(table, '1', where=where, report=report, **kwdata)
1010
+ result = self.select(path, '1', where=where, report=report, **kwdata)
989
1011
  count = len(tuple(result))
990
1012
 
991
1013
  return count
@@ -993,7 +1015,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
993
1015
 
994
1016
  def exist(
995
1017
  self,
996
- table: str,
1018
+ path: str | tuple[str, str],
997
1019
  where: str | None = None,
998
1020
  report: bool | None = None,
999
1021
  **kwdata: Any
@@ -1003,7 +1025,9 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
1003
1025
 
1004
1026
  Parameters
1005
1027
  ----------
1006
- table : Table name, can include database name.
1028
+ path : Path.
1029
+ - `str`: Table name.
1030
+ - `tuple[str, str]`: Database name and table name.
1007
1031
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1008
1032
  - `None`: Match all.
1009
1033
  - `str`: Match condition.
@@ -1017,7 +1041,6 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
1017
1041
 
1018
1042
  Examples
1019
1043
  --------
1020
- Parameter `where` and `kwdata`.
1021
1044
  >>> data = [{'id': 1}]
1022
1045
  >>> Database.execute.insert('table', data)
1023
1046
  >>> where = '`id` = :id_'
@@ -1028,7 +1051,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
1028
1051
  """
1029
1052
 
1030
1053
  # Execute.
1031
- result = self.count(table, where, report, **kwdata)
1054
+ result = self.count(path, where, report, **kwdata)
1032
1055
 
1033
1056
  # Judge.
1034
1057
  judge = result != 0
@@ -1223,7 +1246,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1223
1246
 
1224
1247
  async def select(
1225
1248
  self,
1226
- table: str,
1249
+ path: str | tuple[str, str],
1227
1250
  fields: str | Iterable[str] | None = None,
1228
1251
  where: str | None = None,
1229
1252
  group: str | None = None,
@@ -1238,7 +1261,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1238
1261
 
1239
1262
  Parameters
1240
1263
  ----------
1241
- table : Table name, can include database name.
1264
+ path : Path.
1265
+ - `str`: Table name.
1266
+ - `tuple[str, str]`: Database name and table name.
1242
1267
  fields : Select clause content.
1243
1268
  - `None`: Is `SELECT *`.
1244
1269
  - `str`: Join as `SELECT str`.
@@ -1264,19 +1289,19 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1264
1289
  --------
1265
1290
  Parameter `fields`.
1266
1291
  >>> fields = ['id', ':`id` + 1 AS `id_`']
1267
- >>> result = Database.execute.select('table', fields)
1292
+ >>> result = await Database.execute.select('table', fields)
1268
1293
  >>> print(result.to_table())
1269
1294
  [{'id': 1, 'id_': 2}, ...]
1270
1295
 
1271
1296
  Parameter `kwdata`.
1272
1297
  >>> fields = '`id`, `id` + :value AS `id_`'
1273
- >>> result = Database.execute.select('table', fields, value=1)
1298
+ >>> result = await Database.execute.select('table', fields, value=1)
1274
1299
  >>> print(result.to_table())
1275
1300
  [{'id': 1, 'id_': 2}, ...]
1276
1301
  """
1277
1302
 
1278
1303
  # Handle parameter.
1279
- sql = self.handle_select(table, fields, where, group, having, order, limit)
1304
+ sql = self.handle_select(path, fields, where, group, having, order, limit)
1280
1305
 
1281
1306
  # Execute SQL.
1282
1307
  result = await self.execute(sql, report=report, **kwdata)
@@ -1286,7 +1311,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1286
1311
 
1287
1312
  async def insert(
1288
1313
  self,
1289
- table: str,
1314
+ path: str | tuple[str, str],
1290
1315
  data: TableData,
1291
1316
  duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
1292
1317
  report: bool | None = None,
@@ -1297,7 +1322,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1297
1322
 
1298
1323
  Parameters
1299
1324
  ----------
1300
- table : Table name, can include database name.
1325
+ path : Path.
1326
+ - `str`: Table name.
1327
+ - `tuple[str, str]`: Database name and table name.
1301
1328
  data : Insert data.
1302
1329
  duplicate : Handle method when constraint error.
1303
1330
  - `None`: Not handled.
@@ -1316,19 +1343,18 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1316
1343
 
1317
1344
  Examples
1318
1345
  --------
1319
- Parameter `data` and `kwdata`.
1320
1346
  >>> data = [{'key': 'a'}, {'key': 'b'}]
1321
1347
  >>> kwdata = {'value1': 1, 'value2': ':(SELECT 2)'}
1322
- >>> result = Database.execute.insert('table', data, **kwdata)
1348
+ >>> result = await Database.execute.insert('table', data, **kwdata)
1323
1349
  >>> print(result.rowcount)
1324
1350
  2
1325
- >>> result = Database.execute.select('table')
1351
+ >>> result = await Database.execute.select('table')
1326
1352
  >>> print(result.to_table())
1327
1353
  [{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
1328
1354
  """
1329
1355
 
1330
1356
  # Handle parameter.
1331
- sql, kwdata = self.handle_insert(table, data, duplicate, **kwdata)
1357
+ sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
1332
1358
 
1333
1359
  # Execute SQL.
1334
1360
  result = await self.execute(sql, data, report, **kwdata)
@@ -1338,7 +1364,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1338
1364
 
1339
1365
  async def update(
1340
1366
  self,
1341
- table: str,
1367
+ path: str | tuple[str, str],
1342
1368
  data: TableData,
1343
1369
  where_fields: str | Iterable[str] | None = None,
1344
1370
  report: bool | None = None,
@@ -1349,7 +1375,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1349
1375
 
1350
1376
  Parameters
1351
1377
  ----------
1352
- table : Table name, can include database name.
1378
+ path : Path.
1379
+ - `str`: Table name.
1380
+ - `tuple[str, str]`: Database name and table name.
1353
1381
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
1354
1382
  - `Key`: Table field.
1355
1383
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -1374,19 +1402,18 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1374
1402
 
1375
1403
  Examples
1376
1404
  --------
1377
- Parameter `data` and `kwdata`.
1378
1405
  >>> data = [{'key': 'a'}, {'key': 'b'}]
1379
1406
  >>> kwdata = {'value': 1, 'name': ':`key`'}
1380
- >>> result = Database.execute.update('table', data, **kwdata)
1407
+ >>> result = await Database.execute.update('table', data, **kwdata)
1381
1408
  >>> print(result.rowcount)
1382
1409
  2
1383
- >>> result = Database.execute.select('table')
1410
+ >>> result = await Database.execute.select('table')
1384
1411
  >>> print(result.to_table())
1385
1412
  [{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
1386
1413
  """
1387
1414
 
1388
1415
  # Handle parameter.
1389
- sql, data = self.handle_update(table, data, where_fields, **kwdata)
1416
+ sql, data = self.handle_update(path, data, where_fields, **kwdata)
1390
1417
 
1391
1418
  # Execute SQL.
1392
1419
  result = await self.execute(sql, data, report)
@@ -1396,7 +1423,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1396
1423
 
1397
1424
  async def delete(
1398
1425
  self,
1399
- table: str,
1426
+ path: str | tuple[str, str],
1400
1427
  where: str | None = None,
1401
1428
  order: str | None = None,
1402
1429
  limit: int | str | None = None,
@@ -1408,7 +1435,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1408
1435
 
1409
1436
  Parameters
1410
1437
  ----------
1411
- table : Table name, can include database name.
1438
+ path : Path.
1439
+ - `str`: Table name.
1440
+ - `tuple[str, str]`: Database name and table name.
1412
1441
  where : Clause `WHERE` content, join as `WHERE str`.
1413
1442
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
1414
1443
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -1422,16 +1451,15 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1422
1451
 
1423
1452
  Examples
1424
1453
  --------
1425
- Parameter `where` and `kwdata`.
1426
1454
  >>> where = '`id` IN :ids'
1427
1455
  >>> ids = (1, 2)
1428
- >>> result = Database.execute.delete('table', where, ids=ids)
1456
+ >>> result = await Database.execute.delete('table', where, ids=ids)
1429
1457
  >>> print(result.rowcount)
1430
1458
  2
1431
1459
  """
1432
1460
 
1433
1461
  # Handle parameter.
1434
- sql = self.handle_delete(table, where, order, limit)
1462
+ sql = self.handle_delete(path, where, order, limit)
1435
1463
 
1436
1464
  # Execute SQL.
1437
1465
  result = await self.execute(sql, report=report, **kwdata)
@@ -1441,7 +1469,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1441
1469
 
1442
1470
  async def copy(
1443
1471
  self,
1444
- table: str,
1472
+ path: str | tuple[str, str],
1445
1473
  fields: str | Iterable[str] | None = None,
1446
1474
  where: str | None = None,
1447
1475
  limit: int | str | tuple[int, int] | None = None,
@@ -1453,7 +1481,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1453
1481
 
1454
1482
  Parameters
1455
1483
  ----------
1456
- table : Table name, can include database name.
1484
+ path : Path.
1485
+ - `str`: Table name.
1486
+ - `tuple[str, str]`: Database name and table name.
1457
1487
  fields : Select clause content.
1458
1488
  - `None`: Is `SELECT *`.
1459
1489
  - `str`: Join as `SELECT str`.
@@ -1470,16 +1500,15 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1470
1500
 
1471
1501
  Examples
1472
1502
  --------
1473
- Parameter `where` and `kwdata`.
1474
1503
  >>> where = '`id` IN :ids'
1475
1504
  >>> ids = (1, 2, 3)
1476
- >>> result = Database.execute.copy('table', where, 2, ids=ids, id=None, time=':NOW()')
1505
+ >>> result = await Database.execute.copy('table', ['name', 'value'], where, 2, ids=ids)
1477
1506
  >>> print(result.rowcount)
1478
1507
  2
1479
1508
  """
1480
1509
 
1481
1510
  # Handle parameter.
1482
- sql = self.handle_copy(table, fields, where, limit)
1511
+ sql = self.handle_copy(path, fields, where, limit)
1483
1512
 
1484
1513
  # Execute SQL.
1485
1514
  result = await self.execute(sql, report=report, **kwdata)
@@ -1489,7 +1518,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1489
1518
 
1490
1519
  async def count(
1491
1520
  self,
1492
- table: str,
1521
+ path: str | tuple[str, str],
1493
1522
  where: str | None = None,
1494
1523
  report: bool | None = None,
1495
1524
  **kwdata: Any
@@ -1499,7 +1528,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1499
1528
 
1500
1529
  Parameters
1501
1530
  ----------
1502
- table : Table name, can include database name.
1531
+ path : Path.
1532
+ - `str`: Table name.
1533
+ - `tuple[str, str]`: Database name and table name.
1503
1534
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1504
1535
  - `None`: Match all.
1505
1536
  - `str`: Match condition.
@@ -1513,16 +1544,15 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1513
1544
 
1514
1545
  Examples
1515
1546
  --------
1516
- Parameter `where` and `kwdata`.
1517
1547
  >>> where = '`id` IN :ids'
1518
1548
  >>> ids = (1, 2)
1519
- >>> result = Database.execute.count('table', where, ids=ids)
1549
+ >>> result = await Database.execute.count('table', where, ids=ids)
1520
1550
  >>> print(result)
1521
1551
  2
1522
1552
  """
1523
1553
 
1524
1554
  # Execute.
1525
- result = await self.select(table, '1', where=where, report=report, **kwdata)
1555
+ result = await self.select(path, '1', where=where, report=report, **kwdata)
1526
1556
  count = len(tuple(result))
1527
1557
 
1528
1558
  return count
@@ -1530,7 +1560,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1530
1560
 
1531
1561
  async def exist(
1532
1562
  self,
1533
- table: str,
1563
+ path: str | tuple[str, str],
1534
1564
  where: str | None = None,
1535
1565
  report: bool | None = None,
1536
1566
  **kwdata: Any
@@ -1540,7 +1570,9 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1540
1570
 
1541
1571
  Parameters
1542
1572
  ----------
1543
- table : Table name, can include database name.
1573
+ path : Path.
1574
+ - `str`: Table name.
1575
+ - `tuple[str, str]`: Database name and table name.
1544
1576
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1545
1577
  - `None`: Match all.
1546
1578
  - `str`: Match condition.
@@ -1554,18 +1586,17 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1554
1586
 
1555
1587
  Examples
1556
1588
  --------
1557
- Parameter `where` and `kwdata`.
1558
1589
  >>> data = [{'id': 1}]
1559
1590
  >>> Database.execute.insert('table', data)
1560
1591
  >>> where = '`id` = :id_'
1561
1592
  >>> id_ = 1
1562
- >>> result = Database.execute.exist('table', where, id_=id_)
1593
+ >>> result = await Database.execute.exist('table', where, id_=id_)
1563
1594
  >>> print(result)
1564
1595
  True
1565
1596
  """
1566
1597
 
1567
1598
  # Execute.
1568
- result = await self.count(table, where, report, **kwdata)
1599
+ result = await self.count(path, where, report, **kwdata)
1569
1600
 
1570
1601
  # Judge.
1571
1602
  judge = result != 0