GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - litestar-org/sqlspec: A Query Mapper for Python

BranchesTags
Open more actions menu

Latest commit

 

History

694 Commits
694 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
sqlspec
sqlspec
 
 
tests
tests
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
codecov.yml
codecov.yml
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 
zensical.toml
zensical.toml
 
 

Repository files navigation

SQLSpec

SQL-first database execution for Python across synchronous and asynchronous database adapters.

PyPI Python License Docs

Documentation · Quickstart · Databases · Integrations · Playground · API Reference

SQLSpec provides unified synchronous and asynchronous session APIs, SQLGlot-backed parameter compilation, statement caching, schema migrations, Apache Arrow streaming, and typed row mapping without an ORM. Write plain SQL strings, load named statements from .sql files, or compose dialect-portable queries programmatically while keeping full control over your SQL and underlying driver.

Install

uv add sqlspec

Install optional driver, schema validation, or framework extras as needed:

uv add "sqlspec[asyncpg,msgspec,litestar]"

Quickstart

import msgspec

from sqlspec import SQLSpec
from sqlspec.adapters.sqlite import SqliteConfig


class User(msgspec.Struct):
    id: int
    name: str


spec = SQLSpec()
config = spec.add_config(
    SqliteConfig(connection_config={"database": ":memory:"})
)

with spec.provide_session(config) as session:
    session.execute(
        """
        CREATE TABLE users (
            id INTEGER PRIMARY KEY,
            name TEXT
        )
        """
    )
    session.execute(
        """
        INSERT INTO users (name)
        VALUES (:name)
        """,
        name="Ada",
    )
    user = session.select_one(
        """
        SELECT id, name
        FROM users
        WHERE name = :name
        """,
        name="Ada",
        schema_type=User,
    )

Capabilities

Area Overview
Unified Execution Consistent execute, select, select_one, select_one_or_none, select_value, execute_many, select_stream, and transaction APIs across sync and asyncio drivers.
Database Adapters PostgreSQL (asyncpg, psycopg, psqlpy), CockroachDB (asyncpg, psycopg), SQLite (sqlite3, aiosqlite), MySQL & MariaDB (asyncmy, aiomysql, pymysql, mysql-connector-python), Oracle (oracledb), SQL Server (mssql-python, pymssql), Sybase ASE (pymssql), SAP SQL Anywhere (sqlanydb), IBM Db2 (ibm_db), DuckDB (duckdb), BigQuery (google-cloud-bigquery), Cloud Spanner (google-cloud-spanner), ADBC (adbc-driver-manager), and Arrow ODBC (arrow-odbc).
SQL Files & Builder Load named queries from .sql files via SQLFileLoader or build statements with sql.select, sql.insert, sql.update, sql.delete, and sql.merge with cached AST compilation.
Typed Rows & Arrow Project rows into msgspec.Struct, Pydantic, dataclass, TypedDict, or attrs models, or stream pyarrow, polars, and pandas datasets across local, fsspec, and obstore backends.
Integrations & Ops First-party plugins and stores for Litestar, Google ADK, FastAPI, Starlette, Flask, Sanic, Dishka, and Events, plus OpenTelemetry spans, Prometheus metrics, and CLI migrations.

Documentation

  • Learn & Quickstart — progressive tutorials, query patterns, migrations, and production recipes.
  • Database Adapters — capability matrix, driver installation extras, pool configuration, and dialect notes.
  • Framework & AI Integrations — Litestar, Google ADK, Events, FastAPI, Starlette, Flask, Sanic, and Dishka guides.
  • Interactive Playground — zero-install browser SQLite environment powered by Pyodide WebAssembly.
  • API Reference — class, configuration, driver, builder, and CLI reference documentation.

Reference Applications

  • postgres-vertexai-demo — PostgreSQL pgvector semantic search and real-time chat with Litestar and Google ADK.
  • oracledb-vertexai-demo — Oracle vector search with HNSW indexes, Litestar, and Google ADK.

Contributing & License

Contributions are welcome; see the Contributing Guide for local setup and adapter guidelines. Released under the MIT License.

About

A Query Mapper for Python

sqlspec.dev

Topics

adbcaiosqliteasyncmyasyncpgbigqueryduckdblitestarmsgspecmysqloracleoracledbpostgresqlpsqlpypsycopgpydanticsqlsqlitesqlserver

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

108 stars

Watchers

3 watching

Forks

10 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.