@@ -614,6 +614,7 @@ async def execute(
614614 """Runs a single query for a result set.
615615
616616 Args:
617+ desc: description of the transaction, for logging and metrics
617618 decoder - The function which can resolve the cursor results to
618619 something meaningful.
619620 query - The query string to execute
@@ -649,7 +650,7 @@ async def simple_insert(
649650 or_ignore: bool stating whether an exception should be raised
650651 when a conflicting row already exists. If True, False will be
651652 returned by the function instead
652- desc: string giving a description of the transaction
653+ desc: description of the transaction, for logging and metrics
653654
654655 Returns:
655656 Whether the row was inserted or not. Only useful when `or_ignore` is True
@@ -686,7 +687,7 @@ async def simple_insert_many(
686687 Args:
687688 table: string giving the table name
688689 values: dict of new column names and values for them
689- desc: string giving a description of the transaction
690+ desc: description of the transaction, for logging and metrics
690691 """
691692 await self .runInteraction (desc , self .simple_insert_many_txn , table , values )
692693
@@ -700,7 +701,6 @@ def simple_insert_many_txn(
700701 txn: The transaction to use.
701702 table: string giving the table name
702703 values: dict of new column names and values for them
703- desc: string giving a description of the transaction
704704 """
705705 if not values :
706706 return
@@ -755,6 +755,7 @@ async def simple_upsert(
755755 keyvalues: The unique key columns and their new values
756756 values: The nonunique columns and their new values
757757 insertion_values: additional key/values to use only when inserting
758+ desc: description of the transaction, for logging and metrics
758759 lock: True to lock the table when doing the upsert.
759760 Returns:
760761 Native upserts always return None. Emulated upserts return True if a
@@ -1081,6 +1082,7 @@ async def simple_select_one(
10811082 retcols: list of strings giving the names of the columns to return
10821083 allow_none: If true, return None instead of failing if the SELECT
10831084 statement returns no rows
1085+ desc: description of the transaction, for logging and metrics
10841086 """
10851087 return await self .runInteraction (
10861088 desc , self .simple_select_one_txn , table , keyvalues , retcols , allow_none
@@ -1166,6 +1168,7 @@ async def simple_select_onecol(
11661168 table: table name
11671169 keyvalues: column names and values to select the rows with
11681170 retcol: column whos value we wish to retrieve.
1171+ desc: description of the transaction, for logging and metrics
11691172
11701173 Returns:
11711174 Results in a list
@@ -1190,6 +1193,7 @@ async def simple_select_list(
11901193 column names and values to select the rows with, or None to not
11911194 apply a WHERE clause.
11921195 retcols: the names of the columns to return
1196+ desc: description of the transaction, for logging and metrics
11931197
11941198 Returns:
11951199 A list of dictionaries.
@@ -1243,14 +1247,16 @@ async def simple_select_many_batch(
12431247 """Executes a SELECT query on the named table, which may return zero or
12441248 more rows, returning the result as a list of dicts.
12451249
1246- Filters rows by if value of `column` is in `iterable`.
1250+ Filters rows by whether the value of `column` is in `iterable`.
12471251
12481252 Args:
12491253 table: string giving the table name
12501254 column: column name to test for inclusion against `iterable`
12511255 iterable: list
1252- keyvalues: dict of column names and values to select the rows with
12531256 retcols: list of strings giving the names of the columns to return
1257+ keyvalues: dict of column names and values to select the rows with
1258+ desc: description of the transaction, for logging and metrics
1259+ batch_size: the number of rows for each select query
12541260 """
12551261 results = [] # type: List[Dict[str, Any]]
12561262
@@ -1291,7 +1297,7 @@ def simple_select_many_txn(
12911297 """Executes a SELECT query on the named table, which may return zero or
12921298 more rows, returning the result as a list of dicts.
12931299
1294- Filters rows by if value of `column` is in `iterable`.
1300+ Filters rows by whether the value of `column` is in `iterable`.
12951301
12961302 Args:
12971303 txn: Transaction object
@@ -1367,6 +1373,7 @@ async def simple_update_one(
13671373 table: string giving the table name
13681374 keyvalues: dict of column names and values to select the row with
13691375 updatevalues: dict giving column names and values to update
1376+ desc: description of the transaction, for logging and metrics
13701377 """
13711378 await self .runInteraction (
13721379 desc , self .simple_update_one_txn , table , keyvalues , updatevalues
@@ -1426,6 +1433,7 @@ async def simple_delete_one(
14261433 Args:
14271434 table: string giving the table name
14281435 keyvalues: dict of column names and values to select the row with
1436+ desc: description of the transaction, for logging and metrics
14291437 """
14301438 await self .runInteraction (desc , self .simple_delete_one_txn , table , keyvalues )
14311439
@@ -1451,13 +1459,38 @@ def simple_delete_one_txn(
14511459 if txn .rowcount > 1 :
14521460 raise StoreError (500 , "More than one row matched (%s)" % (table ,))
14531461
1454- def simple_delete (self , table : str , keyvalues : Dict [str , Any ], desc : str ):
1455- return self .runInteraction (desc , self .simple_delete_txn , table , keyvalues )
1462+ async def simple_delete (
1463+ self , table : str , keyvalues : Dict [str , Any ], desc : str
1464+ ) -> int :
1465+ """Executes a DELETE query on the named table.
1466+
1467+ Filters rows by the key-value pairs.
1468+
1469+ Args:
1470+ table: string giving the table name
1471+ keyvalues: dict of column names and values to select the row with
1472+ desc: description of the transaction, for logging and metrics
1473+
1474+ Returns:
1475+ The number of deleted rows.
1476+ """
1477+ return await self .runInteraction (desc , self .simple_delete_txn , table , keyvalues )
14561478
14571479 @staticmethod
14581480 def simple_delete_txn (
14591481 txn : LoggingTransaction , table : str , keyvalues : Dict [str , Any ]
14601482 ) -> int :
1483+ """Executes a DELETE query on the named table.
1484+
1485+ Filters rows by the key-value pairs.
1486+
1487+ Args:
1488+ table: string giving the table name
1489+ keyvalues: dict of column names and values to select the row with
1490+
1491+ Returns:
1492+ The number of deleted rows.
1493+ """
14611494 sql = "DELETE FROM %s WHERE %s" % (
14621495 table ,
14631496 " AND " .join ("%s = ?" % (k ,) for k in keyvalues ),
@@ -1474,6 +1507,20 @@ async def simple_delete_many(
14741507 keyvalues : Dict [str , Any ],
14751508 desc : str ,
14761509 ) -> int :
1510+ """Executes a DELETE query on the named table.
1511+
1512+ Filters rows by if value of `column` is in `iterable`.
1513+
1514+ Args:
1515+ table: string giving the table name
1516+ column: column name to test for inclusion against `iterable`
1517+ iterable: list
1518+ keyvalues: dict of column names and values to select the rows with
1519+ desc: description of the transaction, for logging and metrics
1520+
1521+ Returns:
1522+ Number rows deleted
1523+ """
14771524 return await self .runInteraction (
14781525 desc , self .simple_delete_many_txn , table , column , iterable , keyvalues
14791526 )
0 commit comments