Typed async database access for chirp.
SQL in, frozen dataclasses out. Not an ORM.
Basic usage::
from chirp.data import Database
db = Database("sqlite:///app.db")
@dataclass(frozen=True, slots=True)
class User:
id: int
name: str
email: str
users = await db.fetch(User, "SELECT * FROM users WHERE active = ?", True)
user = await db.fetch_one(User, "SELECT * FROM users WHERE id = ?", 42)
SQLite works out of the box. For PostgreSQL, install the driver::
pip install chirp[data-pg] # PostgreSQL
data
| 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
|
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/data/__init__.py:1