Modern Vertica Analytic Database dialect for SQLAlchemy 2.0+ with full support for Async operations, Alembic migrations, and modern Python (3.9 - 3.14+).
Features
Full SQLAlchemy 2.0+ Architecture: Built on DefaultDialect with query caching (supports_statement_cache = True), 2.0 execution semantics, and parameter-bound reflection.
First-Class Async Engine Support: Run queries asynchronously with create_async_engine() and AsyncSession via vertica+vertica_python_async:// without blocking the asyncio event loop.
Alembic Migrations: Native VerticaImpl integration with transactional DDL, type synonym resolution, and index no-op handling (since Vertica utilizes projections).
Multi-Driver Support: * vertica-python (Synchronous pure-Python DBAPI driver) * vertica-python-async (Asynchronous DBAPI adapter for non-blocking asyncio / FastAPI apps) * pyodbc (ODBC driver) * turbodbc (High-speed ODBC driver for Arrow / NumPy / Pandas data workflows)
Rich Vertica Data Types: * Geospatial: GEOMETRY, GEOGRAPHY * Identifiers: native UUID * Large objects: LONG VARCHAR, LONG VARBINARY (up to 32MB) * Complex types: ARRAY, MAP, ROW (Vertica 10+) * Temporal: TIMESTAMPTZ, TIMETZ, INTERVAL
Complete Reflection: Automatic introspection of schemas, tables, temp tables, views, view definitions, columns, primary keys, foreign keys, unique constraints, check constraints, table & column comments.
Installation
Install from PyPI with your desired driver extras:
# Pure Python sync driver (recommended for sync applications)
pip install "sqlalchemy-vertica[vertica-python]"
# Pure Python async driver (for AsyncEngine / FastAPI / asyncio)
pip install "sqlalchemy-vertica[asyncio]"
# ODBC drivers
pip install "sqlalchemy-vertica[pyodbc]"
pip install "sqlalchemy-vertica[turbodbc]"
# Alembic migrations support
pip install "sqlalchemy-vertica[alembic]"
# Install all drivers and tools
pip install "sqlalchemy-vertica[all]"
Connection Strings
import sqlalchemy as sa
from sqlalchemy.ext.asyncio import create_async_engine
# 1. Async (for FastAPI / asyncio applications)
async_engine = create_async_engine(
"vertica+vertica_python_async://user:pwd@host:5433/database?connection_timeout=10"
)
# 2. Sync vertica-python
engine = sa.create_engine(
"vertica+vertica_python://user:pwd@host:5433/database?connection_timeout=10"
)
# 3. PyODBC with connection string
engine_pyodbc = sa.create_engine(
"vertica+pyodbc:///?odbc_connect=DSN%3DVerticaDSN"
)
# 4. Turbodbc with DSN
engine_turbodbc = sa.create_engine(
"vertica+turbodbc:///?DSN=VerticaDSN"
)
Quick Start
Synchronous SQLAlchemy 2.0
from sqlalchemy import create_engine, text
engine = create_engine("vertica+vertica_python://user:pwd@localhost:5433/mydb")
with engine.connect() as conn:
result = conn.execute(text("SELECT version()"))
print(result.scalar())
# Transaction block
with engine.begin() as conn:
conn.execute(
text("INSERT INTO my_table (name) VALUES (:name)"),
{"name": "Alice"}
)
Asynchronous SQLAlchemy 2.0 & FastAPI
import asyncio
from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
async def main():
engine = create_async_engine(
"vertica+vertica_python_async://user:pwd@localhost:5433/mydb",
pool_size=10,
)
async with engine.connect() as conn:
result = await conn.execute(text("SELECT 1"))
print(result.scalar())
# Using AsyncSession
session_factory = async_sessionmaker(engine, class_=AsyncSession)
async with session_factory() as session:
result = await session.execute(text("SELECT COUNT(*) FROM my_table"))
print("Count:", result.scalar())
await engine.dispose()
asyncio.run(main())
Alembic Migrations
In your Alembic env.py, simply import sqlalchemy_vertica:
import sqlalchemy_vertica # Registers VerticaImpl plugin automatically
from alembic import context
# configure context
context.configure(
connection=connection,
target_metadata=target_metadata,
transactional_ddl=True,
)
Vertica does not support traditional B-tree indexes (it utilizes projections). sqlalchemy-vertica treats index creation/dropping as safe no-ops in migrations to ensure multi-database migration scripts run seamlessly.
Custom Data Types
from sqlalchemy import Column, Integer, Table, MetaData
from sqlalchemy_vertica import (
GEOMETRY,
GEOGRAPHY,
UUID,
LONG_VARCHAR,
ARRAY,
MAP,
ROW,
TIMESTAMPTZ,
)
metadata = MetaData()
places = Table(
"places",
metadata,
Column("id", Integer, primary_key=True, autoincrement=True),
Column("guid", UUID, nullable=False),
Column("description", LONG_VARCHAR),
Column("location", GEOMETRY(srid=4326)),
Column("tags", ARRAY(LONG_VARCHAR)),
Column("metadata", MAP(LONG_VARCHAR, LONG_VARCHAR)),
Column("created_at", TIMESTAMPTZ),
)
Testing & Coverage
Run the automated test suite with pytest and pytest-cov:
pytest -v --cov=sqlalchemy_vertica --cov-report=term-missing
Support
If you find this project helpful and want to support its maintenance and development, you can buy me a coffee:
License
MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlalchemy_vertica-1.0.1.tar.gz.
File metadata
- Download URL: sqlalchemy_vertica-1.0.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0a380b82bf977714670495a7bde1123e983a26d94223cc3f36ac86c75e5be15
|
|
| MD5 |
a4763d8ddba696109407fbd6b751c1f3
|
|
| BLAKE2b-256 |
82b9d7f53311072e898f6fab174ce04b425a474abf36c288a08376985c836bb8
|
Provenance
The following attestation bundles were made for sqlalchemy_vertica-1.0.1.tar.gz:
Publisher:
release.yml on lv10/sqlalchemy-vertica
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemy_vertica-1.0.1.tar.gz -
Subject digest:
d0a380b82bf977714670495a7bde1123e983a26d94223cc3f36ac86c75e5be15 - Sigstore transparency entry: 2581393627
- Sigstore integration time:
-
Permalink:
lv10/sqlalchemy-vertica@01599db6adc401e621cf97cd20c24fb700417361 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lv10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@01599db6adc401e621cf97cd20c24fb700417361 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqlalchemy_vertica-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy_vertica-1.0.1-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9512fbbd3a9d0ad9503fc266d014d4b9a3ad85fd3d6d7b1ee254c0a1ca140db
|
|
| MD5 |
50e08f8af78a4026e56e9c64f8a8d482
|
|
| BLAKE2b-256 |
2a9870d8b43db869c3defc7f0ab0faa3b02030fd855bbf2c86d1090addad390c
|
Provenance
The following attestation bundles were made for sqlalchemy_vertica-1.0.1-py3-none-any.whl:
Publisher:
release.yml on lv10/sqlalchemy-vertica
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemy_vertica-1.0.1-py3-none-any.whl -
Subject digest:
b9512fbbd3a9d0ad9503fc266d014d4b9a3ad85fd3d6d7b1ee254c0a1ca140db - Sigstore transparency entry: 2581393641
- Sigstore integration time:
-
Permalink:
lv10/sqlalchemy-vertica@01599db6adc401e621cf97cd20c24fb700417361 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lv10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@01599db6adc401e621cf97cd20c24fb700417361 -
Trigger Event:
push
-
Statement type: