Registry / database / sqlalchemy-vertica-python

sqlalchemy-vertica-python

JSON →
library0.6.3pypypiunverified

sqlalchemy-vertica-python is a Vertica dialect for SQLAlchemy that utilizes the pure-Python DB-API driver `vertica-python` for database connectivity. It is currently at version 0.6.3, actively maintained by BlueLabs, and typically releases updates to align with SQLAlchemy versions or address bugs.

pip install sqlalchemy-vertica-python
INSTALL
IMPORT
SIG · SQLALCHEMY-VERTICA
S
sqlalchemy-vertica-python
databasepythonv0.6.3
Install
1.8s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.8s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_engine
from sqlalchemy import create_engine
from sqlalchemy import create_engine

This quickstart demonstrates how to establish a connection to a Vertica database using `sqlalchemy-vertica-python` and execute a simple query to retrieve the database version. Ensure your Vertica instance is accessible and replace placeholder credentials with actual environment variables or direct values.

import os from sqlalchemy import create_engine, text # Environment variables for connection details (replace with your Vertica credentials) VERTICA_USER = os.environ.get('VERTICA_USER', 'dbadmin') VERTICA_PASSWORD = os.environ.get('VERTICA_PASSWORD', 'password') VERTICA_HOST = os.environ.get('VERTICA_HOST', 'localhost') VERTICA_PORT = os.environ.get('VERTICA_PORT', '5433') VERTICA_DB = os.environ.get('VERTICA_DB', 'VMart') # Construct the connection string connection_string = ( f"vertica+vertica_python://{VERTICA_USER}:{VERTICA_PASSWORD}" f"@{VERTICA_HOST}:{VERTICA_PORT}/{VERTICA_DB}" ) try: # Create an engine instance engine = create_engine(connection_string) # Establish a connection with engine.connect() as connection: # Execute a simple query result = connection.execute(text("SELECT version();")) # Fetch and print the result for row in result: print(f"Connected to Vertica. Version: {row[0]}") except Exception as e: print(f"Error connecting to Vertica or executing query: {e}")
Debug
Known issues
breakingVersion 0.6.0 introduced a significant update to support SQLAlchemy 2.0 syntax. Projects using older versions of `sqlalchemy-vertica-python` (pre-0.6.0) with SQLAlchemy 1.x will need to migrate their code to be compatible with SQLAlchemy 2.0 practices if upgrading the dialect.
fix
Review the SQLAlchemy 2.0 migration guide and update application code accordingly. For connection string usage, ensure `create_engine` is used. Consider pinning `sqlalchemy` to a 1.x version if immediate migration to 2.0 is not feasible with older dialect versions.
affects: >=0.6.0
gotchaIt is crucial to explicitly close database connections. After using `engine.connect()`, ensure `connection.close()` is called, followed by `engine.dispose()`. Failing to do so can lead to resource leaks as Python's garbage collector might remove resources before the Vertica connector properly closes the session.
fix
Always use `with engine.connect() as connection:` to ensure connections are properly closed, or manually call `connection.close()` and `engine.dispose()` when managing connections manually.
affects: All
gotchaThe PyPI project classifies its development status as '3 - Alpha'. This indicates that the library might still be evolving, features could be limited, and support may vary.
fix
Be aware of potential limitations and ensure thorough testing in production environments. Consider contributing to the project for missing features.
affects: All
gotchaWhen using `pandas.DataFrame.to_sql()` with `sqlalchemy-vertica-python`, there might be issues with `VARCHAR` columns if string variables are not explicitly cast. The dialect might default to `TEXT` which can cause problems.
fix
Explicitly define the `dtype` mapping for string columns to `sqlalchemy.types.VARCHAR` when using `df.to_sql` to ensure correct type inference and prevent issues.
affects: All
Upgrade
Version history
0.6.3latest on PyPI · released Jun 5, 2023
Audit
Dependencies
sqlalchemyrequiredCore dependency for database abstraction. Version 0.6.0+ is compatible with SQLAlchemy 2.0.
vertica-pythonrequiredThe underlying DB-API driver used by the dialect for Vertica connectivity. The dialect installation typically handles this dependency.
Agent activity
30 hits · last 30 days
node
26
Meta
2
OpenAI (training)
1
Resources
sqlalchemy-vertica-python — pip install sqlalchemy-vertica-python · libregistry