SQLite driver helpers for chirp.data.
For file-backed databases the "pool" is a small bounded set ofAsyncConnection
instances. WAL mode (enabled per connection) lets SQLite serve many concurrent
readers alongside a single writer, so readers acquire any pooled connection
without the app-wide write lock; write serialization is handled at the
Databaselayer.
In-memory databases (sqlite:///:memory: / sqlite://) are special. A
plain:memory:connection is private to whichever connection opened it, so a
multi-connection pool would hand each task its own empty database. Shared-cache
mode (file::memory:?cache=shared) lets connections see one logical database
but uses coarse table-level locks that raiseSQLITE_LOCKED(not retried by
busy_timeout) under concurrent reader/writer access. So in-memory databases
use a single shared connection (pool_sizeis treated as 1) and the
Database layer serializes all access — reads included — on _sqlite_lock.
In-memory is a development/test convenience; concurrent-reader throughput is a
file-database (WAL) property. WAL is unavailable for memory DBs (stays
journal_mode=memory) so the PRAGMA is skipped there.
data.drivers.sqlite
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Extract the file path from a sqlite:// URL.
True when the parsed path refers to an in-memory database.
Covers:memory: and the empty path (sqlite://), plus any explicit
file:...:memory:...shared-cache URI.
Resolve the connection target for a parsed SQLite path.
Returns(target, uri, in_memory):
target— the string handed tosqlite3.connect.uri—…
A small bounded pool of async SQLite connections.
Exposesacquire() / release()mirroring the asyncpg pool API so the
Databasefacade can treat both…
Create a small bounded pool of SQLite connections.
File-backed pools size byconfig.pool_size(minimum 1) with WAL mode per connection so SQLite serves concurrent…
parse_sqlite_path
function
def parse_sqlite_path(url: str) -> str
Extract the file path from a sqlite:// URL.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
url
|
str
|
— |
is_memory_path
function
def is_memory_path(path: str) -> bool
True when the parsed path refers to an in-memory database.
Covers:memory: and the empty path (sqlite://), plus any explicit
file:...:memory:...shared-cache URI.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path
|
str
|
— |
_connect_target
function
def _connect_target(path: str) -> tuple[str, bool, bool]
Resolve the connection target for a parsed SQLite path.
Returns(target, uri, in_memory):
target— the string handed tosqlite3.connect.uri— whetheruri=Truemust be passed (shared-cache memory DBs).in_memory— whether this is an in-memory database (skips WAL).
In-memory databases collapse to a single shared connection (see module
docstring), so a plain:memory:target is sufficient — every query runs
on that one connection rather than a per-task private empty database.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path
|
str
|
— |
SqlitePool
class
A small bounded pool of async SQLite connections.
Exposesacquire() / release()mirroring the asyncpg pool API so the
Databasefacade can treat both backends uniformly. Connections are never
bound to a task — theDatabaselayer owns per-task assignment via the
_current_conn ContextVar — so a connection handed out by acquire()
is exclusively held until the matchingrelease().
In-memory databases (is_memory=True) hold exactly one shared connection
so every task sees the same logical database; theDatabaselayer
serializes all in-memory access (reads included) since a lone SQLite
connection cannot safely take concurrent thread-pool dispatches.
create_pool
function
async
async def create_pool(config: DatabaseConfig) -> SqlitePool
Create a small bounded pool of SQLite connections.
File-backed pools size byconfig.pool_size(minimum 1) with WAL mode per
connection so SQLite serves concurrent readers alongside a single writer.
In-memory databases collapse to a single shared connection (skipping WAL,
which is unavailable for:memory:) so every task sees the same logical
database; theDatabaselayer serializes their access.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
config
|
DatabaseConfig
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/data/drivers/sqlite.py:1