Data Flow

SQLSpec processes SQL statements through a consistent pipeline: statement parsing, parameter normalization, driver execution, and result transformation. This guide keeps things short and points you to deeper examples when you need them.

Pipeline Overview

        flowchart LR
  A[SQL / QueryBuilder] --> B[StatementConfig]
  B --> C[Driver Adapter]
  C --> D[Result Objects]
    

Minimal Execution Example

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

db_path = tmp_path / "selects.db"
spec = SQLSpec()
config = spec.add_config(SqliteConfig(connection_config={"database": str(db_path)}))

with spec.provide_session(config) as session:
    session.execute("create table if not exists teams (id integer primary key, name text)")
    session.execute("insert into teams (name) values ('Litestar'), ('SQLSpec')")
    result = session.execute("select id, name from teams order by id")
    print(result.all())

Next Steps