adbc Adapter¶
from sqlspec.adapters.adbc import (
AdbcConfig,
AdbcConnectionParams,
AdbcDriver,
AdbcDriverFeatures,
AdbcExceptionHandler,
AdbcPoolConfig,
)
Apache Arrow Database Connectivity (ADBC) adapter supporting zero-copy Arrow ingest and result streaming across PostgreSQL, SQLite, DuckDB, Snowflake, BigQuery, FlightSQL, GizmoSQL, Oracle, and IBM Db2. Inherited execution methods are documented on SyncDriverAdapterBase. See the ADBC Setup Guide for driver URI patterns and bulk Arrow ingestion.
Configuration & Parameters¶
AdbcConfig
¶
Bases: SyncDatabaseConfig[AdbcConnection, AdbcConnectionPool | AdbcConnection | None, AdbcDriver]
ADBC configuration for Arrow Database Connectivity.
ADBC provides an interface for connecting to multiple database systems with Arrow-native data transfer.
Supports multiple database backends including PostgreSQL, SQLite, DuckDB, BigQuery, and Snowflake with automatic driver detection and loading.
AdbcConnectionParams
¶
Bases: TypedDict
ADBC connection parameters across PyPI-installable Arrow Database Connectivity drivers.
Attributes:
| Name | Type | Description |
|---|---|---|
host |
NotRequired[str]
|
Database server or proxy endpoint hostname (for example Teradata or Snowflake). |
port |
NotRequired[int | str]
|
Database server endpoint port (for example Teradata |
user |
NotRequired[str]
|
Alias for the connection username on Teradata and Snowflake. |
adbc_dialect |
NotRequired[str]
|
Explicit database dialect for generic FlightSQL transports. |
uri |
NotRequired[str]
|
Backend connection URI (such as |
dsn |
NotRequired[str]
|
Connection string alias normalized to |
url |
NotRequired[str]
|
Connection URL alias normalized to |
connection_string |
NotRequired[str]
|
Connection string alias normalized to |
db |
NotRequired[str]
|
Database path or identifier alias normalized for file-backed and embedded ADBC drivers. |
path |
NotRequired[str]
|
Filesystem database path for |
driver |
NotRequired[str]
|
Short driver alias (such as |
driver_name |
NotRequired[str]
|
Explicit ADBC Python module connect path or shared library name overriding URI inference. |
db_kwargs |
NotRequired[dict[str, Any]]
|
Driver-specific |
conn_kwargs |
NotRequired[dict[str, Any]]
|
Driver-specific |
entrypoint |
NotRequired[str]
|
C symbol entrypoint name when loading a shared-object ADBC driver directly. |
profile |
NotRequired[str]
|
Named credential or configuration profile forwarded to cloud ADBC drivers. |
auth_type |
NotRequired[str]
|
Authentication mechanism (for example |
adbc_driver_manager_entrypoint |
NotRequired[str]
|
Explicit |
autocommit |
NotRequired[bool]
|
Enable autocommit mode on newly opened DB-API ADBC connections. |
isolation_level |
NotRequired[str]
|
Transaction isolation level applied to the ADBC connection. |
batch_size |
NotRequired[int]
|
Target Arrow |
query_timeout |
NotRequired[float]
|
Per-statement execution timeout in seconds forwarded to supporting ADBC backends. |
connection_timeout |
NotRequired[float]
|
Connection establishment timeout in seconds. |
ssl_mode |
NotRequired[str]
|
TLS verification mode forwarded to PostgreSQL and compatible ADBC drivers. |
ssl_cert |
NotRequired[str]
|
Client TLS certificate path for mutual TLS connections. |
ssl_key |
NotRequired[str]
|
Client TLS private key path paired with |
ssl_ca |
NotRequired[str]
|
Root CA bundle path used to verify server TLS certificates. |
username |
NotRequired[str]
|
Database authentication username lifted into |
password |
NotRequired[str]
|
Database authentication password lifted into |
token |
NotRequired[str]
|
Bearer, OAuth refresh, or Quack/FlightSQL authentication token. |
auth_token_provider |
NotRequired[Callable[[], str]]
|
Callable returning a fresh password or bearer token on each |
project_id |
NotRequired[str]
|
Google Cloud project ID mapped to |
dataset_id |
NotRequired[str]
|
Default BigQuery dataset ID mapped to |
account |
NotRequired[str]
|
Snowflake account identifier for |
warehouse |
NotRequired[str]
|
Snowflake virtual warehouse name activated on connect. |
database |
NotRequired[str]
|
Target catalog or database name for Snowflake, PostgreSQL, or FlightSQL backends. |
schema |
NotRequired[str]
|
Default schema name for Snowflake or multi-schema ADBC backends. |
role |
NotRequired[str]
|
Session role activated on connect for Snowflake or role-aware backends. |
authorization_header |
NotRequired[str]
|
Explicit HTTP/gRPC |
grpc_options |
NotRequired[dict[str, Any]]
|
Low-level gRPC channel options forwarded to FlightSQL, GizmoSQL, or Quack transports. |
grpc_max_message_size |
NotRequired[int]
|
Maximum inbound gRPC message size in bytes for Arrow Flight transfers. |
fetch_timeout |
NotRequired[float]
|
Timeout in seconds when fetching Arrow Flight result streams. |
gizmosql_backend |
NotRequired[str]
|
Underlying SQL engine dialect hint when connecting through |
tls_skip_verify |
NotRequired[bool]
|
Disable server certificate verification on TLS-enabled FlightSQL or GizmoSQL endpoints. |
tls_root_certs |
NotRequired[str]
|
PEM-encoded root certificate bundle for FlightSQL or GizmoSQL TLS verification. |
mtls_cert_chain |
NotRequired[str]
|
PEM-encoded client certificate chain for FlightSQL or GizmoSQL mTLS. |
mtls_private_key |
NotRequired[str]
|
PEM-encoded client private key paired with |
with_cookie_middleware |
NotRequired[bool]
|
Enable stateful session cookie middleware on FlightSQL/GizmoSQL connections. |
headers |
NotRequired[dict[str, str]]
|
Custom gRPC metadata headers attached to FlightSQL or GizmoSQL requests. |
extra |
NotRequired[dict[str, Any]]
|
Additional driver options merged into |
region |
NotRequired[str]
|
Snowflake cloud region identifier. |
protocol |
NotRequired[str]
|
Snowflake endpoint transport protocol. |
application |
NotRequired[str]
|
Client application identifier. |
keep_session_alive |
NotRequired[bool]
|
Keep the Snowflake session active during idle intervals. |
login_timeout |
NotRequired[int | float | str]
|
Authentication timeout in seconds or a Go duration string. |
request_timeout |
NotRequired[int | float | str]
|
HTTP request timeout in seconds or a Go duration string. |
client_timeout |
NotRequired[int | float | str]
|
Overall client timeout in seconds or a Go duration string. |
ocsp_fail_open_mode |
NotRequired[bool]
|
Allow connections when the certificate status responder is unreachable. |
use_high_precision |
NotRequired[bool]
|
Return fixed-point Snowflake numbers as lossless Arrow decimal values by default. |
okta_url |
NotRequired[str]
|
Okta authentication endpoint URL. |
identity_provider |
NotRequired[str]
|
Workload identity provider name. |
workload_identity_provider |
NotRequired[str]
|
Alias for identity_provider. |
private_key |
NotRequired[str | bytes | Path | Any]
|
JWT private key as PEM text, DER bytes, a path, or a private key object. |
private_key_passphrase |
NotRequired[str | bytes]
|
Passphrase for an encrypted private key. |
jwt_private_key |
NotRequired[str | Path]
|
Filesystem path to a private key. |
jwt_private_key_pkcs8_value |
NotRequired[str]
|
In-memory PKCS8 private key text. |
jwt_private_key_pkcs8_password |
NotRequired[str]
|
Passphrase for the in-memory private key. |
jwt_expire_timeout |
NotRequired[int | float | str]
|
JWT lifetime in seconds or a Go duration string. |
query_tag |
NotRequired[str]
|
Default Snowflake query tag for session and statement correlation. |
session_parameters |
NotRequired[Mapping[str, Any]]
|
Additional Snowflake session parameters. |
AdbcPoolConfig
¶
Bases: TypedDict
Optional PostgreSQL clone-pool bounds; an empty mapping enables defaults.
Attributes:
| Name | Type | Description |
|---|---|---|
max_size |
NotRequired[int]
|
Maximum simultaneous clone leases, excluding the original seed (default 4). |
timeout |
NotRequired[float]
|
Maximum seconds to wait for a lease (default 30.0). |
AdbcDriverFeatures
¶
Bases: TypedDict
ADBC driver feature flags controlling Arrow type handling, dialect probes, and DuckDB profiling.
Attributes:
| Name | Type | Description |
|---|---|---|
json_serializer |
NotRequired[Callable[[Any], str]]
|
Serializer converting dict/list parameters to JSON text (defaults to |
enable_cast_detection |
NotRequired[bool]
|
Detect explicit SQL casts such as |
enable_strict_type_coercion |
NotRequired[bool]
|
Raise an error on unsupported parameter types instead of best-effort conversion (defaults to |
enable_arrow_extension_types |
NotRequired[bool]
|
Preserve PyArrow extension type metadata when materializing Arrow results (defaults to |
enable_pgvector |
NotRequired[bool]
|
Probe |
enable_paradedb |
NotRequired[bool]
|
Probe |
enable_pg_textsearch |
NotRequired[bool]
|
Probe |
enable_lowercase_column_names |
NotRequired[bool]
|
Normalize unquoted uppercase column names to lowercase (defaults to |
enable_events |
NotRequired[bool]
|
Enable SQLSpec table-backed event channel support. |
on_connection_create |
NotRequired[Callable[[AdbcConnection], None]]
|
Callback invoked with the raw ADBC connection immediately after |
events_backend |
NotRequired[Literal['poll_queue']]
|
Event queue backend name ( |
query_tag |
NotRequired[str]
|
Default Snowflake statement tag combined with the current correlation ID. |
enable_statement_profiling |
NotRequired[bool]
|
Capture per-statement DuckDB JSON operator profiles on |
Driver, Pool & Data Dictionary¶
AdbcDriver
¶
Bases: SyncDriverAdapterBase
ADBC driver for Arrow Database Connectivity.
Provides database connectivity through ADBC with support for multiple database dialects, parameter style conversion, and transaction management.
AdbcExceptionHandler
¶
Bases: BaseSyncExceptionHandler
Context manager for handling ADBC database exceptions.
Captures underlying ADBC driver errors and exposes mapped SQLSpec exceptions
on pending_exception.
AdbcDataDictionary
¶
Extension Stores & Configs¶
AdbcStore
¶
Bases: BaseSQLSpecStore['AdbcConfig']
ADBC session store using synchronous ADBC driver.
Implements server-side session storage for Litestar using ADBC (Arrow Database Connectivity) via the synchronous driver. Uses Litestar's sync_to_thread utility to provide an async interface compatible with the Store protocol.
ADBC supports multiple database backends (PostgreSQL, SQLite, DuckDB, etc.). The SQL schema is optimized for PostgreSQL by default, but can work with other backends that support TIMESTAMPTZ and BYTEA equivalents.
Provides efficient session management with
- Sync operations wrapped for async compatibility
- INSERT ON CONFLICT (UPSERT) for PostgreSQL
- Automatic expiration handling with TIMESTAMPTZ
- Efficient cleanup of expired sessions
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
AdbcConfig
|
AdbcConfig instance. |
required |
AdbcADKConfig
¶
Bases: ADKConfig
ADBC-specific ADK extension settings.
Use these keys inside extension_config["adk"] with the ADBC ADK stores.
Attributes:
| Name | Type | Description |
|---|---|---|
enable_bm25 |
NotRequired[bool]
|
Enable pg_textsearch BM25 indexing for hybrid vector search on PostgreSQL. Defaults to False. |
vector_dimensions |
NotRequired[int]
|
Dimensions for the vector embedding column on PostgreSQL. Defaults to 768. |
vector_index_type |
NotRequired[Literal['hnsw', 'ivfflat', 'scann', 'none']]
|
Vector index type for PostgreSQL. Defaults to 'hnsw'. |
scann_num_leaves |
NotRequired[int]
|
Number of leaves for ScaNN index on PostgreSQL. Defaults to 100. |
scann_quantizer |
NotRequired[Literal['SQ8', 'FP32']]
|
Quantizer for ScaNN index on PostgreSQL. Defaults to 'SQ8'. |
AdbcADKStore
¶
Bases: BaseSyncADKStore['AdbcConfig']
ADBC synchronous ADK store for Arrow Database Connectivity.
Implements session and event storage for Google Agent Development Kit using ADBC. ADBC provides a vendor-neutral API with Arrow-native data transfer across multiple databases (PostgreSQL, SQLite, DuckDB, etc.).
Events use the clean-break contract: id, session_id, invocation_id, timestamp, and event_data. The full ADK Event payload is stored as a single JSON blob in event_data using a dialect-appropriate column type (JSONB for PostgreSQL, JSON for DuckDB and BigQuery, VARIANT for Snowflake, TEXT for SQLite and generic fallback).
Provides
- Session state management with JSON serialization
- Event history tracking via single event_data blob
- Atomic event insert + session state update
- Timezone-aware timestamps
- Foreign key constraints with cascade delete
- Database-agnostic SQL (supports multiple backends)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
AdbcConfig
|
AdbcConfig with extension_config["adk"] settings. |
required |
AdbcADKMemoryStore
¶
Bases: BaseSyncADKMemoryStore['AdbcConfig']
ADBC synchronous ADK memory store for Arrow Database Connectivity.
AdbcEventQueueStore
¶
Bases: BaseEventQueueStore['AdbcConfig']
Event queue store for ADBC with multi-dialect support.
ADBC supports multiple database backends, so this store dynamically generates DDL appropriate for the detected dialect. Each dialect produces different column types and table structures.
Dialect detection is performed once on first access and cached for the lifetime of the store instance (database type never changes).
Supported dialects
- PostgreSQL: JSONB columns, TIMESTAMPTZ, partial indexes
- SQLite: TEXT columns, TIMESTAMP (default fallback)
- DuckDB: JSON columns, TIMESTAMP
- Oracle: CLOB columns, TIMESTAMP WITH TIME ZONE, PL/SQL existence guards
- IBM Db2: CLOB(1M) columns, TIMESTAMP, SQLSTATE existence handlers
- SQL Server: NVARCHAR(MAX) columns, DATETIME2, OBJECT_ID / sys.indexes guards
- BigQuery: JSON/STRING columns, CLUSTER BY (no indexes)
- Snowflake: VARIANT columns, no indexes supported
- FlightSQL: Uses SQLite-compatible types (TEXT, TIMESTAMP)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
AdbcConfig
|
AdbcConfig with extension_config["events"] settings. |
required |
Teradata transport¶
AdbcConfig supports Columnar dbc Teradata driver manifests and explicit teradata dialect routing for Flight SQL. See Teradata setup for installation and transaction restrictions.