aiosqlite
Native execution adapter for aiosqlite (sqlite+aiosqlite:// URLs).
AiosqliteAdapter
Bases: DriverAdapter
Runs bound statements on an aiosqlite connection, which takes ?-style
SQL and a sequence of arguments::
| Text Only | |
|---|---|
1 | |
aiosqlite raises the standard sqlite3 exceptions, which are DBAPI
classes already, so they need no mapping. SQLite reports no column types,
so result processors are looked up without them, as SQLAlchemy does.
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
__init__(dialect)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dialect
|
Dialect
|
dialect of the connected database |
required |
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
36 37 38 39 40 41 42 | |
execute(raw, bound)
async
Run a write statement. The inserted primary key comes from RETURNING
when the statement has it (SQLite 3.35+), else from lastrowid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
pooled raw connection |
required |
bound
|
BoundStatement
|
statement to execute |
required |
Returns:
| Type | Description |
|---|---|
Any
|
inserted primary key for INSERT, row count otherwise |
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
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 | |
execute_many(raw, batch)
async
Run a statement once per row with aiosqlite's executemany.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
pooled raw connection |
required |
batch
|
BoundBatch
|
statement and arguments per row |
required |
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
98 99 100 101 102 103 104 105 106 107 108 109 110 | |
fetch_all(raw, bound, as_tuples=False)
async
Run a statement and return all rows keyed by result label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
pooled raw connection |
required |
bound
|
BoundStatement
|
statement to execute |
required |
as_tuples
|
bool
|
return tuples of values in select order instead |
False
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
rows |
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
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 | |
stream(raw, bound, batch_size)
async
Stream rows of a statement, fetching batch_size rows at a time.
No execution lock is taken: aiosqlite has none, as it runs every call
in order on its own thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Any
|
pooled raw connection |
required |
bound
|
BoundStatement
|
statement to execute |
required |
batch_size
|
int
|
rows fetched per round trip |
required |
Returns:
| Type | Description |
|---|---|
AsyncGenerator[Dict[str, Any], None]
|
rows keyed by result label |
Source code in ormar/databases/native/adapters/aiosqlite.py
| Python | |
|---|---|
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |