API Reference
Curated module-by-module and per-adapter API reference for SQLSpec. Every page opens with the canonical public import path, links to the corresponding conceptual guide, and documents public classes, protocols, TypedDict schemas, and functions without duplicating inherited driver methods across database adapters.
Core & Root Modules
| Public Import Path |
Reference Page |
Summary |
sqlspec / sqlspec.base |
SQLSpec Registry |
Central SQLSpec registry for configurations, sessions, pools, named SQL files, and cache controls. |
sqlspec.config |
Configuration |
SyncDatabaseConfig, AsyncDatabaseConfig, NoPoolSyncConfig, NoPoolAsyncConfig, MigrationConfig, and extension config TypedDict schemas. |
sqlspec.driver |
Driver Overview |
SyncDriverAdapterBase, AsyncDriverAdapterBase, and shared driver types. |
sqlspec.core |
Core Pipeline |
SQL & StatementConfig, results, parameters, filters, cache, and compiler. |
sqlspec.builder |
Query Builders |
sql factory, Select, DML builders, DDL builders, and expression wrappers. |
sqlspec.loader |
SQL File Loader |
SQLFileLoader, SQLFile, NamedStatement, and SlotDeclaration. |
| Public Import Path |
Reference Page |
Summary |
sqlspec.migrations |
Migrations |
SyncMigrationCommands, AsyncMigrationCommands, runners, trackers, loaders, and squash helpers. |
sqlspec.storage |
Storage & Pipelines |
StorageRegistry, SyncStoragePipeline, AsyncStoragePipeline, and Arrow storage bridge jobs. |
sqlspec.service |
Service Layer |
SQLSpecSyncService and SQLSpecAsyncService base classes for framework-agnostic data services. |
sqlspec.data_dictionary |
Data Dictionary |
Cross-database schema introspection metadata (TableMetadata, ColumnMetadata, IndexMetadata, VersionInfo) and topological dependency sorting. |
sqlspec.dialects |
SQLGlot Dialects |
Custom SQLGlot dialects (Spanner, Spangres, DB2, PGVector, ParadeDB, PGTextSearch). |
sqlspec.observability |
Observability |
ObservabilityConfig, TelemetryConfig, StatementEvent, RedactionConfig, and cloud log formatters. |
sqlspec.cli |
CLI Reference |
sqlspec command-line interface options, migration subcommands, and ADK maintenance commands. |
Types, Protocols, Exceptions & Extensions
| Public Import Path |
Reference Page |
Summary |
sqlspec.exceptions |
Exceptions |
SQLSpecError hierarchy (IntegrityError, UniqueViolationError, DeadlockError, SerializationConflictError) and map_sqlstate_to_exception. |
sqlspec.protocols |
Protocols |
Runtime-checkable structural protocols for drivers, cursors, builders, and Arrow results. |
sqlspec.typing |
Typing & Schema Aliases |
SupportedSchemaModel, StatementParameters, ArrowReturnFormat, and optional dependency sentinels. |
sqlspec.utils |
Utilities |
Type guards, serializers, schema converters, UUID/NanoID generators, fixture loaders, and sync/async bridges. |
sqlspec.extensions.* |
Extensions |
Litestar, Google ADK, Events, FastAPI, Starlette, Flask, Sanic, OpenTelemetry, and Prometheus. |
sqlspec.adapters.* |
Database Adapters |
Adapter-specific configurations, connection/pool TypedDict parameters, drivers, and extension stores across all database adapters. |