Introduction#
SQLSpec is a SQL first data access layer. It keeps you close to SQL while adding type-safe results, consistent driver APIs, and optional tooling for query construction and observability.
What SQLSpec does#
Write the SQL you want. SQLSpec validates and normalizes statements before execution.
Map rows into typed objects like msgspec, Pydantic, or dataclasses.
One API for sync/async drivers across PostgreSQL, SQLite, DuckDB, MySQL, Oracle, and more.
Use the fluent SQL builder and instrument queries with OpenTelemetry or Prometheus.
Not an ORM#
SQLSpec is intentionally not an ORM. It optimizes for SQL-first workflows.
Focus |
SQLSpec |
Traditional ORM |
|---|---|---|
Abstraction |
Minimal, SQL-centric |
Model-centric, hides SQL |
Core use case |
Query mapper + data integration |
Object graphs + unit-of-work |
Data workflows |
Fast, explicit, Arrow-friendly |
Heavier mapping and state tracking |
Good fit when#
You prefer writing SQL and want predictable behavior.
You need consistent APIs across multiple databases.
You care about performance, type safety, and data‑engineering workflows.
You want optional tools rather than a full ORM stack.