query_executor
QueryExecutor module - executes database queries using SQLAlchemy async API.
QueryExecutor
Executes database queries using SQLAlchemy async API. Provides a databases-compatible interface.
Source code in ormar/databases/query_executor.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__init__(connection)
Initialize query executor.
:param connection: SQLAlchemy async connection
Source code in ormar/databases/query_executor.py
19 20 21 22 23 24 25 | |
execute(query)
async
Execute a query (INSERT, UPDATE, DELETE).
:param query: SQLAlchemy query expression :return: For INSERT, returns last row id; for UPDATE/DELETE, returns row count
Source code in ormar/databases/query_executor.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
execute_many(query, values)
async
Execute a query multiple times with different parameter sets.
:param query: SQLAlchemy query expression or SQL string :param values: Sequence of parameter mappings
Source code in ormar/databases/query_executor.py
81 82 83 84 85 86 87 88 89 90 91 | |
fetch_all(query)
async
Execute a query and fetch all rows.
:param query: SQLAlchemy query expression :return: List of Row objects
Source code in ormar/databases/query_executor.py
27 28 29 30 31 32 33 34 35 | |
fetch_one(query)
async
Execute a query and fetch one row.
:param query: SQLAlchemy query expression :return: Single Row object or None
Source code in ormar/databases/query_executor.py
37 38 39 40 41 42 43 44 45 46 | |
fetch_val(query, column=0)
async
Execute a query and fetch a single scalar value.
:param query: SQLAlchemy query expression :param column: Column index to fetch (default 0) :return: Scalar value or None
Source code in ormar/databases/query_executor.py
48 49 50 51 52 53 54 55 56 57 | |
iterate(query)
async
Execute a query and iterate over results.
:param query: SQLAlchemy query expression :return: Async iterator of Row objects
Source code in ormar/databases/query_executor.py
93 94 95 96 97 98 99 100 101 102 | |