Database Drivers, Analytics & Cloud Dialers¶
vertebra.db provides database configs, sync and async drivers, capability protocols, DB-API 2.0 adapters, Apache Arrow cursors, DataFusion SQL federation, change data capture, tenant scoping, and direct Cloud SQL and AlloyDB dialers. See the Databases & Native Drivers Usage Guide for patterns and examples.
| Category | Coverage |
|---|---|
| SQLSpec Adapters | Litestar adapter configs under vertebra.extensions.sqlspec backed by Vertebra drivers and connection leasing. |
| PEP 249 DB-API | Sync and async DB-API 2.0 interfaces under vertebra.db.dbapi with no SQLAlchemy dependency. |
| Registry & Driver Contracts | URL-based driver resolution, shared pool keys, uniform sync and async contracts, query pipelining, and zero-copy Arrow cursors. |
| Capability Protocols | Runtime-checkable protocols for pipelining, pub/sub notifications, CDC streams, SKIP LOCKED queues, and in-database embedding pushdown. |
| Relational & Analytical Drivers | Configs for PostgreSQL, MySQL, SQLite, Oracle 26ai, SQL Server, DuckDB, BigQuery, and Spanner. |
| Key-Value & Federated SQL | RESP3 Redis and Valkey clients with client-side caching, Sentinel, and Cluster routing, plus cross-engine DataFusion analytics. |
| Cloud Dialers, CDC & RLS | Direct IAM token auth, :5433 AlloyDB and :3307 Cloud SQL mTLS connectors, logical replication and change streams, and tenant isolation. |
Registry, Driver Contracts & Pipelines¶
DatabaseRegistry and provide_driver resolve configs and shared drivers from URL schemes. SyncDatabaseDriver and AsyncDatabaseDriver define the execution contract, while SyncPipelineCapable and AsyncPipelineCapable add batched driver.pipeline() execution.
DatabaseRegistry
¶
Named registry of configured database, cache, analytics, and cloud dialer instances.
parse_url
¶
Parse a database, cache, analytics, or dialer URL into its typed configuration struct.
get_driver
¶
Lazily instantiate and return the asynchronous driver for the given alias.
get_sync_driver
¶
Lazily instantiate and return the synchronous driver for the given alias.
get_dialer
¶
Return a cached Cloud SQL or AlloyDB dialer for config and sync mode.
provide_driver
¶
Resolve a database, cache, or analytics driver from DatabaseRegistry for framework DI.
BaseDatabaseConfig
¶
SyncDatabaseDriver
¶
Bases: CommonDriverMixin[ConfigT]
Base execution contract for synchronous SQL and analytical database drivers.
AsyncDatabaseDriver
¶
Bases: CommonDriverMixin[ConfigT]
Base execution contract for asynchronous SQL and analytical database drivers.
DatabaseError
¶
Bases: VertebraError
Base error raised for database driver, wire-protocol, or query execution failures.
SyncPipelineCapable
¶
AsyncPipelineCapable
¶
ArrowCursor
¶
Zero-copy shared-memory Arrow IPC cursor for bulk analytical result sets.
_shm_anchor pins the source region and memoryviews backing _buffer so Arrow buffers
decoded over the payload never outlive the mapping, _ipc_table_cache memoizes the
pyarrow.Table when pyarrow is installed, and _native_ipc_cursor lazily memoizes
vertebra._vertebra.ArrowCursor.from_ipc_bytes only when pyarrow is absent.
PEP 249 DB-API¶
SyncDBAPIConnection
¶
Bases: _BaseDBAPIConnection
Standalone synchronous PEP 249 connection backed by Vertebra native drivers.
AsyncDBAPIConnection
¶
Bases: _BaseDBAPIConnection
Standalone asynchronous PEP 249 connection backed by Vertebra async drivers.
SyncDBAPIModule
¶
Bases: _BaseDBAPIModule
Standalone synchronous PEP 249 DBAPI 2.0 module descriptor.
AsyncDBAPIModule
¶
Bases: _BaseDBAPIModule
Standalone asynchronous DBAPI module adapter returning AsyncDBAPIConnection instances.
Relational, Cloud & Analytical Drivers¶
PostgreSQLConfig
¶
Bases: BaseDatabaseConfig
PostgreSQL configuration supporting Cloud SQL, AlloyDB, and PgBouncer/PgCat/pgdog poolers.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect | str | Default: 'postgres' |
dialect_tag | int | Default: POSTGRES_DIALECT_TAG |
url_schemes | tuple[str, ...] | Default: ('postgresql', 'postgres') |
driver_module | str | Default: 'vertebra.db.adapters.postgres.driver' |
sync_driver_name | str | Default: 'SyncPostgreSQLDriver' |
async_driver_name | str | Default: 'AsyncPostgreSQLDriver' |
dsn | str | Primary PostgreSQL connection URI (may point to a PgBouncer, PgCat, or pgdog pooler). |
direct_dsn | str | None | Optional unpooled direct PostgreSQL URI used for |
pooler_mode | PoolerMode | Connection pooler multiplexing mode ( |
pgbouncer | bool | When True, configure transaction-mode PgBouncer settings ( |
pgbouncer_mode | bool | Alias for |
protocol_level_pooler_cache | bool | When True, retain prepared statements in transaction-mode poolers supporting protocol-level statement caching. |
max_prepared_statements | int | None | Maximum per-connection prepared statement LRU capacity ( |
min_size | int | Minimum number of pooled connections maintained per worker. |
max_size | int | Maximum number of pooled connections permitted per worker. |
enable_cloud_sql | bool | When True, enable zero-sidecar Google Cloud SQL (:3307) mTLS connection dialing. |
cloud_sql_instance | str | None | Optional Google Cloud SQL instance connection name ( |
cloud_sql_ip_type | Literal['PUBLIC', 'PRIVATE', 'PSC'] | Preferred Google Cloud SQL IP connectivity mode. |
enable_alloydb | bool | When True, enable zero-sidecar Google Cloud AlloyDB (:5433) mTLS and MetadataExchange dialing. |
alloydb_instance_uri | str | None | Optional Google Cloud AlloyDB instance URI ( |
alloydb_ip_type | Literal['PUBLIC', 'PRIVATE', 'PSC'] | Preferred Google Cloud AlloyDB IP connectivity mode. |
connector_retry_count | int | Maximum retry attempts on transient Cloud SQL or AlloyDB dialer errors (defaults to |
connector_retry_delay | float | Initial backoff delay in seconds before jittered exponential dialer retries (defaults to |
connector_retry_max_delay | float | Upper bound in seconds on exponential backoff between dialer retry attempts (defaults to |
enable_iam_auth | bool | When True, authenticate using short-lived Google Cloud IAM OAuth2 tokens (on direct :5432 TCP/TLS or :3307/:5433 dialers). |
iam_auth_options | Mapping[str, str] | Optional |
token_provider | Any | Optional cloud database token provider ( |
ca_pem | str | None | Optional inline Root CA PEM bundle used for PostgreSQL TLS verification. |
enable_alloydb_columnar_engine | bool | When True, enable |
cockroach_cluster | str | None | Optional CockroachDB cluster routing identifier forwarded as |
application_name | str | PostgreSQL |
statement_timeout_ms | int | None | Optional per-statement execution timeout in milliseconds ( |
idle_in_transaction_session_timeout_ms | int | None | Optional timeout in milliseconds before aborting idle open transactions. |
session_gucs | Mapping[str, str] | Additional PostgreSQL session GUC key-value pairs applied on connection startup. |
broker | Any | Optional shared-memory |
effective_statement_cache_size | int | Return the prepared statement cache capacity safe for the configured pooler mode. |
effective_direct_dsn | str | Return the direct primary DSN for LISTEN/NOTIFY, logical replication, and migrations. |
MySQLConfig
¶
Bases: BaseDatabaseConfig
Configuration for SyncMySQLDriver and AsyncMySQLDriver.
ssl_mode holds only what the caller set; None means unset. canonical_ssl_mode resolves the
effective mode: an explicit DSN ssl parameter, then the ssl_mode field, then a default. The default is
verify-full for AwsRdsIamTokenProvider or AzureEntraTokenProvider on a remote host, require for
any other token provider or for loopback, unix-socket, and Cloud SQL targets, and prefer without a
token provider. Remote cloud IAM targets reject explicit disable and prefer.
SQLiteConfig
¶
Bases: BaseDatabaseConfig
Configuration for SQLite 3.45+ with WAL mode, memory-mapped I/O, and SHM broker leasing.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect | str | Default: 'sqlite' |
dialect_tag | int | Default: SQLITE_DIALECT_TAG |
url_schemes | tuple[str, ...] | Default: ('sqlite',) |
driver_module | str | Default: 'vertebra.db.adapters.sqlite.driver' |
sync_driver_name | str | Default: 'SyncSQLiteDriver' |
async_driver_name | str | Default: 'AsyncSQLiteDriver' |
path | str | Filesystem path to the SQLite database file or |
wal_mode | bool | When True, enable |
synchronous | str | SQLite |
mmap_size | int | Maximum memory-mapped I/O window in bytes ( |
busy_timeout_ms | int | Lock contention wait timeout in milliseconds ( |
max_readers | int | Maximum number of concurrent read connections leased across workers. |
foreign_keys | bool | When True, enforce referential integrity via |
broker | Any | Optional shared-memory |
database | str | Path | None | Optional alias for |
enable_jsonb | bool | When True, use SQLite 3.45+ binary |
is_in_memory | bool | Return True if the target database is in-memory. |
OracleConfig
¶
Bases: BaseDatabaseConfig
Configuration for the Oracle driver backed by the native vertebra._oracle module.
MSSQLConfig
¶
DuckDBConfig
¶
Bases: BaseDatabaseConfig
Configuration for the embedded DuckDB analytical engine.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect | str | Default: 'duckdb' |
dialect_tag | int | Default: DUCKDB_DIALECT_TAG |
url_schemes | tuple[str, ...] | Default: ('duckdb',) |
driver_module | str | Default: 'vertebra.db.adapters.duckdb.driver' |
sync_driver_name | str | Default: 'SyncDuckDBDriver' |
async_driver_name | str | Default: 'AsyncDuckDBDriver' |
path | str | Filesystem path to the DuckDB database file or |
database | str | Fallback database path alias used when |
memory_limit_mb | int | Maximum buffer manager memory allowance in MiB ( |
threads | int | Number of DuckDB execution threads ( |
temp_directory | str | None | Optional spill directory configured via |
parquet_metadata_cache | bool | When True, enable |
httpfs_connection_caching | bool | When True, keep remote HTTP/object-storage connections warm ( |
enable_http_metadata_cache | bool | When True, cache remote HTTP/Parquet |
read_only | bool | When True, open the DuckDB file in read-only mode allowing multi-process readers. |
secrets | tuple[DuckDBSecretConfig | Mapping[str, Any], ...] | Optional DuckDB secrets ( |
extensions | tuple[str, ...] | Optional DuckDB extensions ( |
init_statements | tuple[str, ...] | Optional SQL statements executed after bootstrap on every pooled session. |
config | dict[str, str] | Optional DuckDB session |
pool_min_size | int | Minimum number of pooled DuckDB cursors per worker. |
pool_max_size | int | Maximum number of pooled DuckDB cursors per worker. |
statement_cache_size | int | Maximum number of prepared analytical statements cached per worker. |
broker | Any | Optional shared-memory |
BigQueryConfig
¶
Bases: BaseDatabaseConfig
Configuration for SyncBigQueryDriver and AsyncBigQueryDriver.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect | str | Default: 'bigquery' |
dialect_tag | int | Default: BIGQUERY_DIALECT_TAG |
url_schemes | tuple[str, ...] | Default: ('bigquery', 'bq') |
driver_module | str | Default: 'vertebra.db.adapters.bigquery.driver' |
sync_driver_name | str | Default: 'SyncBigQueryDriver' |
async_driver_name | str | Default: 'AsyncBigQueryDriver' |
requires_statement_autocommit | bool | Default: True |
project_id | str | Google Cloud project identifier owning BigQuery jobs and default datasets. |
dataset_id | str | None | Default BigQuery dataset identifier for unqualified table references. |
location | str | BigQuery dataset and job processing location (such as |
dsn | str | None | Optional |
rest_endpoint | str | Base URL for the BigQuery REST v2 API. |
storage_endpoint | str | Endpoint URL for the BigQuery Storage Read/Write v1 gRPC API. |
maximum_bytes_billed | int | None | Optional FinOps byte billing cap applied to executed query jobs. |
job_timeout_ms | int | None | Optional server-side query execution timeout in milliseconds. |
priority | Literal['INTERACTIVE', 'BATCH'] | BigQuery query scheduling priority ( |
labels | dict[str, str] | Static key-value labels attached to BigQuery jobs after label sanitization. |
credentials_path | str | None | Optional filesystem path to a Google Cloud service-account or ADC JSON file. |
service_account_key | str | dict[str, Any] | None | Optional inline service-account JSON string or mapping. |
quota_project_id | str | None | Optional |
impersonate_service_account | str | None | Optional target service-account email for keyless IAM Credentials |
access_token | str | None | Optional static OAuth2 bearer access token override. |
use_gcloud_cli | bool | Whether to force token minting via the local |
scopes | tuple[str, ...] | OAuth2 scopes requested when minting bearer tokens. |
pool_size | int | Maximum pooled HTTP/1.1 and HTTP/2 |
statement_cache_capacity | int | Maximum entries retained in the shared-memory SQL statement plan cache. |
use_shm_cache | bool | Whether to enable the cross-worker POSIX shared-memory statement cache. |
arrow_compression | Literal['LZ4_FRAME', 'ZSTD', 'UNSPECIFIED'] | Arrow IPC stream compression codec negotiated with BigQuery Storage Read API v1. |
max_read_streams | int | Maximum parallel |
ca_pem | bytes | None | PEM root certificates added to the REST API client. The Storage Read/Write API clients use the system trust store and ignore this value. |
broker | Any | Optional shared-memory |
SpannerConfig
¶
Bases: BaseDatabaseConfig
Configuration for SyncSpannerDriver and AsyncSpannerDriver.
Attributes:
| Name | Type | Description |
|---|---|---|
dialect_tag | int | Default: SPANNER_GOOGLESQL_DIALECT_TAG |
url_schemes | tuple[str, ...] | Default: ('spanner', 'spangres', 'spanner+googlesql', 'spanner+spangres') |
driver_module | str | Default: 'vertebra.db.adapters.spanner.driver' |
sync_driver_name | str | Default: 'SyncSpannerDriver' |
async_driver_name | str | Default: 'AsyncSpannerDriver' |
requires_statement_autocommit | bool | Default: True |
project_id | str | Google Cloud project identifier owning the Spanner instance. |
instance_id | str | Cloud Spanner instance identifier. |
database_id | str | Cloud Spanner database identifier. |
dsn | str | None | Optional |
database_role | str | None | Optional fine-grained access control (FGAC) |
dialect | Literal['googlesql', 'spangres'] | SQL dialect configured on the Spanner database ( |
endpoint | str | Cloud Spanner v1 gRPC endpoint URI. |
admin_endpoint | str | None | REST endpoint for DDL ( |
pool_size | int | Number of pooled HTTP/2 |
route_to_leader_enabled | bool | Whether |
max_commit_delay_ms | int | None | Optional |
data_boost_enabled | bool | Whether |
max_partitions | int | Maximum parallel |
credentials_path | str | None | Optional filesystem path to a Google Cloud service-account or ADC JSON file. |
service_account_key | str | dict[str, Any] | None | Optional inline service-account JSON string or mapping. |
quota_project_id | str | None | Optional |
impersonate_service_account | str | None | Optional target service-account email for keyless IAM Credentials |
use_gcloud_cli | bool | Whether to force token minting via the local |
scopes | tuple[str, ...] | OAuth2 scopes requested when minting bearer tokens. |
access_token | str | None | Optional static bearer token override for testing or workload federation. |
use_shm_cache | bool | Whether to enable the cross-worker POSIX shared-memory statement cache. |
statement_cache_capacity | int | Maximum entries retained in the shared-memory SQL statement plan cache. |
ca_pem | bytes | None | PEM root certificates for a non-googleapis |
broker | Any | Optional shared-memory |
database_uri | str | Return the canonical |
database_path | str | Return the canonical |
Key-Value Stores & DataFusion¶
RedisConfig
¶
Bases: BaseRESPConfig
Configuration for Redis 7.2+ / 8.0+ standalone, Sentinel, and Cluster connections.
ValkeyConfig
¶
Bases: BaseRESPConfig
Configuration for Valkey 8.0+ / 9.0+ standalone, Sentinel, Cluster, and GCP Memorystore.
DataFusionConfig
¶
Bases: BaseDatabaseConfig
Configuration for embedded in-process Apache DataFusion analytics execution.
DataFusionEngine
¶
Federated query engine joining ObjectStore datasets with live database Arrow tables.
register_table
¶
Register an ObjectStore dataset, file source, or registered Arrow table.
register_arrow_table
¶
Normalize and register an in-memory PyArrow table or ArrowCursor on the session context.
register_parquet_from_store
¶
Register a Parquet dataset located in an ObjectStore.
execute_arrow
¶
Execute sql on the DataFusion SessionContext and return a PyArrow Table.
Cloud Dialers, CDC & Row-Level Security¶
AlloyDBConfig
¶
CloudSQLConfig
¶
ChangeFeed
¶
Publish change-feed envelopes with bounded history and spill storage.
TenantPredicate
¶
TenantScopeConfig.setting_name is adapter-neutral. TenantPredicate renders ANSI placeholders with an optional CAST, while the PostgreSQL and Oracle adapters own session SQL. SQLSpec accepts the declared PostgreSQL and Oracle setters and rejects other engines. BigQuery and Spanner constructors reject a non-None tenant_predicate before initialization. Oracle VPD scopes support trusted context package procedures alongside DBMS_SESSION.SET_IDENTIFIER and reset or evict connections on pool release.
See Database Capabilities for notification, change-stream, tenant-scope, and tool-provider APIs.