Module

data._sqlite

Async SQLite wrapper using stdlib sqlite3 + anyio.

Zero external dependencies for SQLite support. Runs all blocking sqlite3 calls in a worker thread viaanyio.to_thread.

Uses Python 3.12+ features:

  • check_same_thread=False: safe for anyio's thread pool dispatch
  • autocommit=True: individual statements auto-commit; chirp's
    ``transaction()`` context manager flips to manual mode as needed
    

Free-threading note (3.14t): check_same_thread=False is required because anyio.to_thread dispatches to a pool — different calls may land on different threads. SQLite in WAL mode with serialized threading handles this safely.

Classes

AsyncCursor 6
Async wrapper around ``sqlite3.Cursor``.

Async wrapper aroundsqlite3.Cursor.

Methods

description 0 Any
property
def description(self) -> Any
Returns
Any
rowcount 0 int
property
def rowcount(self) -> int
Returns
int
fetchall 0 list[Any]
async
async def fetchall(self) -> list[Any]
Returns
list[Any]
fetchone 0 Any
async
async def fetchone(self) -> Any
Returns
Any
fetchmany 1 list[Any]
async
async def fetchmany(self, size: int = 100) -> list[Any]
Parameters
Name Type Description
size Default:100
Returns
list[Any]
Internal Methods 1
__init__ 1
def __init__(self, cursor: sqlite3.Cursor) -> None
Parameters
Name Type Description
cursor
AsyncConnection 11
Async wrapper around ``sqlite3.Connection``.

Async wrapper aroundsqlite3.Connection.

Methods

row_factory 0 Any
property
def row_factory(self) -> Any
Returns
Any
autocommit 0 bool
property
def autocommit(self) -> bool
Returns
bool
row_factory 1
def row_factory(self, factory: Any) -> None
Parameters
Name Type Description
factory
autocommit 1
def autocommit(self, value: bool) -> None
Parameters
Name Type Description
value
execute 2 AsyncCursor
async
async def execute(self, sql: str, params: Sequence[Any] = ()) -> AsyncCursor
Parameters
Name Type Description
sql
params Default:()
Returns
AsyncCursor
executemany 2 AsyncCursor
async
async def executemany(self, sql: str, params_seq: Sequence[Sequence[Any]]) -> AsyncCursor
Parameters
Name Type Description
sql
params_seq
Returns
AsyncCursor
executescript 1
Execute multiple SQL statements at once. Useful for migrations with multiple s…
async
async def executescript(self, sql: str) -> None

Execute multiple SQL statements at once.

Useful for migrations with multiple statements (CREATE + INDEX, etc.). Note:executescriptimplicitly commits any pending transaction before running, and does not honorautocommitmode.

Parameters
Name Type Description
sql
commit 0
async
async def commit(self) -> None
rollback 0
async
async def rollback(self) -> None
close 0
async
async def close(self) -> None
Internal Methods 1
__init__ 1
def __init__(self, conn: sqlite3.Connection) -> None
Parameters
Name Type Description
conn

Functions

connect 1 AsyncConnection
Open an async SQLite connection. Uses ``autocommit=True`` so individual statem…
async
async def connect(path: str) -> AsyncConnection

Open an async SQLite connection.

Usesautocommit=Trueso individual statements commit immediately. Usescheck_same_thread=Falsefor safe use with anyio's thread pool.

Parameters
Name Type Description
path str
Returns
AsyncConnection