Transaction
Wraps an active database transaction.
A fassung.connection.Transaction proxies query methods to its parent fassung.connection.Connection while guarding against use after commit, rollback, or being marked for rollback. Use a fassung.connection.Connection as an async context manager to obtain one.
commit()
async
Commit the transaction.
cursor(type_, query, *, prefetch=None, timeout=None)
Create a cursor factory for iterating over query results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
type[T]
|
The row type to parse each result into. |
required |
query
|
Template
|
A t-string template containing the SQL query. |
required |
prefetch
|
int | None
|
Number of rows to prefetch. |
None
|
timeout
|
float | None
|
Optional query timeout in seconds. |
None
|
execute(query)
async
Execute a SQL command and return its status string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
Template
|
A t-string template containing the SQL to execute. |
required |
fetch(type_, query, *, timeout=None)
async
fetchrow(type_, query, *, timeout=None)
async
fetchval(type_, query, column=0, *, timeout=None)
async
Execute a query and return a single scalar value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
type[T]
|
The expected type of the returned value. |
required |
query
|
Template
|
A t-string template containing the SQL query. |
required |
column
|
int
|
Zero-based column index to extract. |
0
|
timeout
|
float | None
|
Optional query timeout in seconds. |
None
|
mark_for_rollback()
Mark the transaction for rollback.
The transaction cannot be used after this call. The actual rollback is performed when the fassung.connection.Connection context manager exits.
rollback()
async
Roll back the transaction.