{"id":19808136,"url":"https://github.com/vertica/vertica-sqlalchemy-dialect","last_synced_at":"2025-05-01T07:32:05.841Z","repository":{"id":65202255,"uuid":"580784019","full_name":"vertica/vertica-sqlalchemy-dialect","owner":"vertica","description":"Official Vertica SQLAlchemy dialect to connect Vertica and SQLAlchemy applications.","archived":false,"fork":false,"pushed_at":"2024-08-01T12:40:19.000Z","size":116,"stargazers_count":3,"open_issues_count":7,"forks_count":9,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-27T05:26:30.450Z","etag":null,"topics":["database","dialect","python","sqlalchemy"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/vertica-sqlalchemy-dialect/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vertica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-21T12:47:37.000Z","updated_at":"2025-01-18T07:59:55.000Z","dependencies_parsed_at":"2024-06-21T20:24:04.081Z","dependency_job_id":"86e9f50e-ec7b-487f-bf9f-c486ea584897","html_url":"https://github.com/vertica/vertica-sqlalchemy-dialect","commit_stats":{"total_commits":8,"total_committers":4,"mean_commits":2.0,"dds":0.625,"last_synced_commit":"004321d0006c67a14f3861856346736206c0f29a"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertica%2Fvertica-sqlalchemy-dialect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertica%2Fvertica-sqlalchemy-dialect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertica%2Fvertica-sqlalchemy-dialect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertica%2Fvertica-sqlalchemy-dialect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vertica","download_url":"https://codeload.github.com/vertica/vertica-sqlalchemy-dialect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251840337,"owners_count":21652320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","dialect","python","sqlalchemy"],"created_at":"2024-11-12T09:13:05.968Z","updated_at":"2025-05-01T07:32:05.532Z","avatar_url":"https://github.com/vertica.png","language":"Python","readme":"# Vertica SQLAlchemy Dialect\n\n[![Build and Test](https://github.com/vertica/vertica-sqlalchemy-dialect/actions/workflows/dialecttest.yml/badge.svg)](https://github.com/vertica/vertica-sqlalchemy-dialect/actions/workflows/dialecttest.yml)\n[![PyPi](https://img.shields.io/pypi/v/vertica-sqlalchemy-dialect.svg)](https://pypi.python.org/pypi/vertica-sqlalchemy-dialect/)\n[![License Apache-2.0](https://img.shields.io/:license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n\nVertica dialect for SQLAlchemy uses the pure-Python DB-API driver vertica-python, to connect a Vertica database and SQLAlchemy applications.\n\nThis repo was derived from a series of chained forks as outlined in the [Acknowledgement](https://github.com/vertica/vertica-sqlalchemy-dialect/blob/main/ACKNOWLEDGMENTS).\n\n\u003e **Warning**\n\u003e This dialect currently doesn't not have state-of-the-art features and support maybe limited based on Vertica developer availability. However, we encourage you to raise a PR to add new features that may help your SQLAlchemy application.\n\n## Prerequisites\n\nYou will need the following softwares to run, build and test the dialect. Everything apart from Python and pip can be installed via pip itself.\n\n1. Python 3.x or higher\n2. pip 22 or higher\n3. sqlalchemy\u003e=1.3.24,\u003c=1.4.44\n4. vertica-python 1.1.1 or higher\n\n### Vertica-Python\n\n[vertica-python](https://github.com/vertica/vertica-python) is needed to use the Vertica-SQLAlchemy-Dialect. The connector does not need to be installed as the dialect installation takes care of it.\n\nNote: We recommend using the vertica-python connector. However, the dialect also allows connecting using [pyodbc](https://pypi.org/project/pyodbc/). More instructions are at the end of this README.\n\n\n## Installing Vertica SQLAlchemy Dialect\n\nThe Vertica SQLAlchemy package can be installed from the public PyPI repository using `pip`:\n\n```shell\npip install --upgrade vertica-sqlalchemy-dialect\n```\n\n`pip` automatically installs all required modules, including vertica-python.\n\n## Verifying Your Installation\n\n1. Create a file (e.g. `validate.py`) that contains the following Python sample code,\n   which connects to Vertica and displays the Vertica version:\n\n    Using vertica-python\n    ```python\n    from sqlalchemy import create_engine\n\n    engine = create_engine(\n        'vertica+vertica_python://{user}:{password}@{host}:{port}/{db}'.format(\n            user='\u003cyour_user_login_name\u003e',\n            password='\u003cyour_password\u003e',\n            host='\u003cyour_Host_IP\u003e',\n            port='\u003cyour_db_port\u003e',\n            db='your_db_name'\n        )\n    )\n    try:\n        connection = engine.connect()\n        results = connection.execute('select version()').fetchone()\n        print(results[0])\n    finally:\n        connection.close()\n        engine.dispose()\n    ```\n\n2. Replace the credentials with the values for Vertica DB and user.\n\n    For more details, see [Connection Parameters](https://github.com/vertica/vertica-sqlalchemy-dialect#connection-parameters).\n\n3. Execute the sample code. For example, if you created a file named `validate.py`:\n\n    ```shell\n    python validate.py\n    ```\n\n    The Vertica version (e.g. `v12.0.1`) should be displayed.\n\n## Parameters and Behavior\n\nAs much as possible, Vertica SQLAlchemy provides compatible functionality for SQLAlchemy applications. For information on using SQLAlchemy, see the [SQLAlchemy documentation](http://docs.sqlalchemy.org/en/latest/).\n\nNote: Current state of the dialect only supports metadata functions. It is still under development. \n\nHowever, Vertica SQLAlchemy also provides specific parameters and behavior, which are described in the following sections.\n\n### Connection Parameters\n\nVertica SQLAlchemy Dialect uses the following syntax for the connection string used to connect to Vertica and initiate a session:\n\n```python\n'vertica+vertica_python://\u003cuser\u003e:\u003cpassword\u003e@\u003chost_name\u003e/\u003cdatabase_name\u003e'\n```\n\nWhere:\n\n- `\u003cuser\u003e` is the login name for your Vertica user.\n- `\u003cpassword\u003e` is the password for your Vertica user.\n- `\u003chost_name\u003e` is the IP/FQDN of your Vertica Host.\n- `\u003cdatabase_name\u003e` is the name of your Vertica Database.\n\n\nYou can optionally specify the initial database and schema for the Vertica session by including them at the end of the connection string, separated by `/`. You can also specify other supported parameters by vertica-python at the end of the connection string:\n\n```python\n'vertica+vertica_python://\u003cuser\u003e:\u003cpassword\u003e@\u003chost_name\u003e/\u003cdatabase_name\u003e?session_label=sqlalchemy\u0026connection_load_balance=1'\n```\nFor more information, check out the connection [options](https://github.com/vertica/vertica-python#set-properties-with-connection-string) of vertica-python.\n\n### Opening and Closing Connection\n\nOpen a connection by executing `engine.connect()`; avoid using `engine.execute()`. Make certain to close the connection by executing `connection.close()` before\n`engine.dispose()`; otherwise, the Python Garbage collector removes the resources required to communicate with Vertica, preventing the Python connector from closing the session properly.\n\n```python\n# Example\nengine = create_engine(...)\nconnection = engine.connect()\ntry:\n    connection.execute(\u003cSQL\u003e)\nfinally:\n    connection.close()\n    engine.dispose()\n```\n\n## Using pyodbc instead of vertica-python\n\nYou may use pyodbc instead of vertica-python for the connection.\n\n### Create a Vertica DSN \n\n\nYou will need to have a Vertica ODBC driver installed from [Vertica-Client-Drivers](https://www.vertica.com/download/vertica/client-drivers/). For steps to install ODBC for Vertica, follow official [Vertica Docs](https://www.vertica.com/docs/12.0.x/HTML/Content/Authoring/ConnectingToVertica/ClientODBC/InstallingODBC.htm).\n\nFor example, you will need to configure these files with your credentials:\n\n`/etc/vertica.ini`\n```\n[Driver]\nErrorMessagesPath = /opt/vertica/lib64/\nODBCInstLib = /usr/lib/x86_64-linux-gnu/libodbcinst.so\nDriverManagerEncoding=UTF-16\n```\n\n`~/.odbc.ini`\n```\n[ODBC Data Sources]\nvertica = \"My Database\"\n\n[verticadsn]\nDescription = My Database\nDriver = /opt/vertica/lib64/libverticaodbc.so\nDatabase = docker\nServername = 127.0.0.1\nUID = dbadmin\nPWD =\n```\n\n\nThen use the Vertica DSN in a file like so:\n```python\nfrom sqlalchemy import create_engine\n\nengine = sa.create_engine('vertica+pyodbc://@verticadsn')\ntry:\n    res = engine.connect().scalar('select version();')\n    print(res)\nfinally:\n    connection.close()\n    engine.dispose()\n\n```\n\nThis should display the Vertica version info: \"Vertica Analytic Database v12.0.0-0\".\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertica%2Fvertica-sqlalchemy-dialect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvertica%2Fvertica-sqlalchemy-dialect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertica%2Fvertica-sqlalchemy-dialect/lists"}