{"id":3814,"library":"sqlalchemy-trino","title":"SQLAlchemy Trino Dialect","description":"sqlalchemy-trino was a Trino (f.k.a. PrestoSQL) dialect for SQLAlchemy. As of version 0.5.0, this project is officially deprecated. Its functionality has been merged into the upstream `trino-python-client` project, which now provides a built-in SQLAlchemy dialect. This library is no longer actively developed.","status":"deprecated","version":"0.5.0","language":"en","source_language":"en","source_url":"https://github.com/dungdm93/sqlalchemy-trino","tags":["SQLAlchemy","Trino","Database","Dialect","Deprecated"],"install":[{"cmd":"pip install sqlalchemy-trino","lang":"bash","label":"Install deprecated library"},{"cmd":"pip install trino[sqlalchemy]","lang":"bash","label":"Recommended: Install official Trino client with SQLAlchemy support"}],"dependencies":[{"reason":"Core SQLAlchemy library for database abstraction.","package":"SQLAlchemy","optional":false},{"reason":"The underlying Trino Python client library. Note that `trino` refers to `trino-python-client` on PyPI.","package":"trino","optional":false}],"imports":[{"note":"The dialect is registered upon package installation; `create_engine` is used from `sqlalchemy` core.","symbol":"create_engine","correct":"from sqlalchemy import create_engine"}],"quickstart":{"code":"import os\nfrom sqlalchemy import create_engine, text\n\n# NOTE: This library is DEPRECATED. The recommended approach is to use trino-python-client directly.\n# pip install trino[sqlalchemy]\n# from sqlalchemy import create_engine\n# engine = create_engine(f\"trino://{os.environ.get('TRINO_USER', 'user')}@{os.environ.get('TRINO_HOST', 'localhost')}:{os.environ.get('TRINO_PORT', '8080')}/{os.environ.get('TRINO_CATALOG', 'system')}/{os.environ.get('TRINO_SCHEMA', 'runtime')}\")\n\n# Example using the deprecated sqlalchemy-trino library:\n\n# Configure connection details via environment variables or replace directly\nTRINO_USER = os.environ.get('TRINO_USER', 'test_user')\nTRINO_HOST = os.environ.get('TRINO_HOST', 'localhost')\nTRINO_PORT = os.environ.get('TRINO_PORT', '8080')\nTRINO_CATALOG = os.environ.get('TRINO_CATALOG', 'system')\nTRINO_SCHEMA = os.environ.get('TRINO_SCHEMA', 'runtime')\n\nconnection_string = (\n    f\"trino://{TRINO_USER}@{TRINO_HOST}:{TRINO_PORT}/{TRINO_CATALOG}/{TRINO_SCHEMA}\"\n)\n\ntry:\n    engine = create_engine(connection_string)\n    with engine.connect() as connection:\n        result = connection.execute(text(\"SELECT 1\"))\n        print(\"Successfully connected to Trino!\")\n        for row in result:\n            print(row)\nexcept Exception as e:\n    print(f\"Error connecting to Trino: {e}\")\n    print(\"Please ensure Trino is running and connection details are correct.\")","lang":"python","description":"Demonstrates how to connect to a Trino server using the `sqlalchemy-trino` dialect. It's crucial to note that this library is deprecated, and the recommended method is to use the `trino[sqlalchemy]` package directly, which provides the same dialect string (`trino://`)."},"warnings":[{"fix":"Migrate your dependencies from `sqlalchemy-trino` to `trino[sqlalchemy]`. The connection string format remains `trino://...`.","message":"The `sqlalchemy-trino` library is officially deprecated as of version 0.5.0. All active development has moved to the `trino-python-client` package, which now includes the SQLAlchemy dialect directly.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Upgrade `sqlalchemy-trino` to 0.4.1 or newer to avoid direct conflicts, or ideally, migrate to using only `trino[sqlalchemy]` and remove `sqlalchemy-trino`.","message":"When `trino-python-client` (PyPI package `trino`) version 0.307.0 or newer is installed, it includes a built-in SQLAlchemy dialect. Installing both `sqlalchemy-trino` and `trino-python-client` might lead to conflicts or unexpected behavior if `sqlalchemy-trino` is older than 0.4.1.","severity":"gotcha","affected_versions":"sqlalchemy-trino <0.4.1 in conjunction with trino-python-client >=0.307.0"},{"fix":"Code that relied on lazy loading of `cursor.description` or custom handling of `TrinoResultProxy` will need adjustment. Custom metadata queries might need to be rewritten to use `information_schema`.","message":"Version 0.4.0 introduced significant changes: `TrinoResultProxy` was removed in favor of eager-loading `cursor.description`, and metadata queries shifted from `SHOW` commands to `information_schema`.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"If your applications implicitly relied on `hive` as the default catalog without explicitly specifying it in the connection string, you will need to update your connection string to include `/hive` if that's still your desired catalog.","message":"The default catalog was changed from `hive` to `system` in version 0.3.0.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}