| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
SQLSpec is a SQL execution layer for Python. You write the SQL -- as strings, through a builder API, or loaded from files. SQLSpec handles connections, parameter binding, and dialect translation. It maps results back to typed Python objects. It uses sqlglot under the hood. Queries are parsed, validated, and optimized before they hit the database.
| Area | Support |
|---|---|
| One API | The same session and result APIs with sync or async drivers. |
| Databases | PostgreSQL, SQLite, DuckDB, MySQL, SQL Server, Oracle, CockroachDB, BigQuery, Spanner, and supported Arrow Database Connectivity backends such as Snowflake, Flight SQL, and GizmoSQL. |
| Data tools | Typed result mapping, Arrow export, built-in storage, and native bulk ingest where the adapter supports it. |
| Frameworks | Litestar, FastAPI, Flask, Sanic, and Starlette. |
pip install sqlspecfrom dataclasses import dataclass
from sqlspec import SQLSpec
from sqlspec.adapters.sqlite import SqliteConfig
@dataclass
class Greeting:
message: str
spec = SQLSpec()
db = spec.add_config(SqliteConfig(connection_config={"database": ":memory:"}))
with spec.provide_session(db) as session:
greeting = session.select_one("SELECT 'Hello, SQLSpec!' AS message", schema_type=Greeting)
print(greeting.message) # Output: Hello, SQLSpec!Write SQL, define a schema, get typed objects back. The getting started guide covers adapter installation and the query builder.
Want to try it without installing anything? The interactive playground runs SQLSpec in your browser with a sandboxed Python runtime.
Contributions are welcome -- whether that's bug reports, new adapter ideas, or pull requests. Take a look at the contributor guide to get started.
MIT
| Back | FazBrowse Home | New Git URL |