advanced-alchemy
Use when working with advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type,…
Use when working with sqlspec, SQLSpec, SQLFileLoader, drivers, query builders, named SQL, filters, pagination, Arrow, framework extensions, ADK stores, or observers. Not for ORM repositories — use advanced-alchemy.
Claude Code
$ npx -y skills add litestar-org/litestar-skills --skill sqlspec --agent claude-code
Codex
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a codex -y
Cursor
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a cursor -y
Gemini CLI
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a gemini-cli -y
GitHub Copilot
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a github-copilot -y
OpenCode
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a opencode -y
Windsurf
$ npx skills add litestar-org/litestar-skills --skill sqlspec -a windsurf -y
name: sqlspec description: "Use when working with sqlspec, SQLSpec, SQLFileLoader, drivers, query builders, named SQL, filters, pagination, Arrow, framework extensions, ADK stores, or observers. Not for ORM repositories — use advanced-alchemy."
SQLSpec is a **type-safe SQL query mapper for Python** -- NOT an ORM. It provides flexible connectivity with consistent interfaces across its database adapter packages. Write raw SQL, use the builder API, or load SQL from files. Statements pass through a sqlglot-powered AST pipeline for validation, parameter handling, and dialect conversion.
sqlspec ships first-party extensions for five web frameworks. If your project uses one of these, **jump directly to the matching integration guide and skip the others**:
Shared topics that apply to every framework live in [`references/commit-modes.md`](references/commit-modes.md) (autocommit / manual middleware) and [`references/multi-database.md`](references/multi-database.md) (multi-config registry). Read the framework guide first, then those for depth.
The rest of this SKILL.md covers framework-agnostic topics: adapter setup, query builder, driver methods, filters, observability, migrations, the ADK extension, and data-dictionary introspection.
from sqlspec import SQLSpec
from sqlspec.adapters.asyncpg import AsyncpgConfig
config = AsyncpgConfig(
connection_config={
"dsn": "postgresql://user:pass@localhost:5432/mydb",
"min_size": 2,
"max_size": 10,
},
)
db_manager = SQLSpec()
db_manager.add_config(config)
async with db_manager.provide_session(config) as db:
users = await db.select(
"SELECT * FROM users WHERE active = $1",
True,
schema_type=User,
)from sqlspec import sql
stmt = (
sql.select("id", "name", "email")
.from_("users")
.where_eq("status", "active")
.where("created_at > :since", since=cutoff_date)
.order_by("created_at", desc=True)
.limit(50)
.to_statement()
)
insert_stmt = (
sql.insert("users").columns("name", "email").values(name="Alice", email="alice@example.com").to_statement()
)
merge_stmt = (
sql.merge("inventory", dialect="postgres")
.using("updates")
.on("inventory.product_id = updates.product_id")
.when_matched_then_update(qty="updates.qty")
.when_not_matched_then_insert(product_id="updates.product_id", qty="updates.qty")
.to_statement()
)| Method | Returns | Use Case | | --- | --- | --- | | `select()` / `fetch()` | List of rows | Filtered queries, listing | | `select_value()` | Single scalar | `COUNT(*)`, `MAX()`, existence checks | | `select_value_or_none()` | Scalar or `None` | Optional scalar lookup | | `select_one()` | One row (strict) | Get-by-ID, raises `NotFoundError` | | `select_one_or_none()` | One row or `None` | Optional lookup | | `select_with_total()` | Rows plus total | Pagination | | `select_stream()` / `fetch_stream()` | Context-managed row stream | Bounded row iteration where adapter supports native streaming | | `select_to_arrow()` / `fetch_to_arrow()` | `ArrowResult` | Bulk data export, analytics | | `select_to_storage()` | `StorageBridgeJob` | Export query results to local or cloud storage | | `execute()` | `SQLResult` | INSERT/UPDATE/DELETE metadata | | `execute_many()` | `SQLResult` | Batch operation metadata | | `execute_script()` | `SQLResult` | Multi-statement SQL script execution | | `execute_stack()` | `tuple[StackResult, ...]` | Ordered statement-stack execution | | `load_from_arrow()` | `StorageBridgeJob` | Adapter-supported Arrow ingest | | `load_from_storage()` | `StorageBridgeJob` | Adapter-supported staged-file ingest | | `load_from_records()` | `StorageBridgeJob` | Records normalized through the Arrow ingest path | | `transaction()` | Context manager | Atomic transaction or savepoint scope on a driver |
arrow_result = await db.select_to_arrow(
"SELECT * FROM large_dataset WHERE region = $1",
region,
return_format="reader",
batch_size=10_000,
)
await db.load_from_arrow("users", arrow_result)
await db.load_from_records("users", [{"id": 1, "name": "Ada"}])<workflow>
| Need | Adapter | Key Feature | | --- | --- | --- | | PostgreSQL async | `asyncpg`, `psycopg` | Async, NUMERIC/PYFORMAT params, auto-probed `pgvector` / `pg_textsearch` / `paradedb` | | PostgreSQL sync | `psycopg` | Sync+async, PYFORMAT params | | SQLite | `sqlite`, `aiosqlite` | QMARK params, local dev | | DuckDB analytics
Opinionated, first-party agent skills, plugins, subagents, hooks, and rules for the Litestar framework and its ecosystem — published from a single-root repository across Google Antigravity, Claude Code, Codex CLI, Cursor, OpenCode, and VS Code / Copilot.
Use when working with advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type,…
Use when working with litestar_autowire, AutowirePlugin, AutowireConfig, domain_packages, AutowireIntegration, AutowireLoader, or…
Use when working with uv build, uv_build, hatch build, PyApp, scie-jump, PYAPP_*, wheel assets, GitHub release matrices,…
Use when working with Dockerfile, compose, Railway, Cloud Run, GKE, systemd, Kubernetes, Terraform, deploy scripts, or…
Use when working with zensical.toml, docs/conf.py, sphinx, shibuya, litestar-sphinx-theme, mkdocstrings, Griffe, objects.inv, or…
Use when working with litestar_email, EmailPlugin, EmailConfig, EmailService, EmailMessage, SMTPConfig, ResendConfig,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.