Documentation for .execute_fn(), refs #685

pull/768/head
Simon Willison 2020-05-08 09:52:53 -07:00 zatwierdzone przez GitHub
rodzic 4433306c18
commit ec9cdc3ffa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 20 dodań i 0 usunięć

Wyświetl plik

@ -155,6 +155,26 @@ The ``Results`` object also has the following properties and methods:
``.__len__()``
Calling ``len(results)`` returns the (truncated) number of returned results.
.. _database_execute_fn:
await db.execute_fn(fn)
-----------------------
Executes a given callback function against a read-only database connection running in a thread. The function will be passed a SQLite connection, and the return value from the function will be returned by the ``await``.
Example usage:
syntax:
.. code-block:: python
def get_version(conn);
return conn.execute(
"select sqlite_version()"
).fetchall()[0][0]
version = await db.execute_fn(get_version)
.. _database_execute_write:
await db.execute_write(sql, params=None, block=False)