{"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":"python","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,"search_vec":"'0.5.0':18 'activ':51 'built':42 'built-in':41 'client':35 'databas':55 'deprec':23,57 'develop':52 'dialect':3,12,45,56 'f.k.a':10 'function':25 'librari':47 'longer':50 'merg':28 'offici':22 'prestosql':11 'project':20,36 'provid':39 'python':34 'sqlalchemi':1,5,14,44,53 'sqlalchemy-trino':4 'trino':2,6,9,33,54 'trino-python-cli':32 'upstream':31 'version':17","created_at":"2026-04-11T17:45:49.980228+00:00","updated_at":"2026-04-16T22:13:44.607747+00:00","problems":[{"fix":"Install `sqlalchemy-trino` using `pip install sqlalchemy-trino`. However, as `sqlalchemy-trino` is deprecated, the recommended fix is to migrate to the `trino-python-client` by installing `pip install trino[sqlalchemy]` and using its dialect.","cause":"The `sqlalchemy-trino` package is either not installed, or SQLAlchemy cannot find and load the `trino` dialect plugin, possibly due to conflicts or an incomplete installation.","error":"sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:trino"},{"fix":"SQLAlchemy dialects are typically loaded implicitly via `create_engine` using the `trino://` scheme in the connection string; direct import of `sqlalchemy_trino` is generally not needed. Ensure `sqlalchemy-trino` (or `trino[sqlalchemy]`) is installed.","cause":"The user is attempting to directly import a module named `sqlalchemy_trino`, which is not the standard way to use a SQLAlchemy dialect plugin.","error":"ModuleNotFoundError: No module named 'sqlalchemy_trino'"},{"fix":"Migrate your codebase to use the SQLAlchemy dialect provided by `trino-python-client`. Install it with `pip install trino[sqlalchemy]` and ensure your `create_engine` calls use the `trino://` scheme, which `trino-python-client` now supports.","cause":"The `sqlalchemy-trino` library is officially deprecated as of version 0.5.0, with its functionality having been merged into the upstream `trino-python-client` project.","error":"sqlalchemy-trino deprecated"},{"fix":"Verify that the schema specified exists within the Trino catalog you are connecting to and that your user has appropriate access. Update the connection string or modify your query to use a valid, existing schema.","cause":"The schema specified in the SQLAlchemy connection string (e.g., `trino://user@host/catalog/my_schema`) or a subsequent query does not exist in the connected Trino catalog, or the user lacks necessary permissions.","error":"DBAPIError: (trino.exceptions.TrinoUserError) TrinoUserError(type=USER_ERROR, name=SCHEMA_NOT_FOUND, message=\"Schema 'my_schema' not found\")"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.5.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/dungdm93/sqlalchemy-trino","docs":null,"changelog":null,"pypi":"https://pypi.org/project/sqlalchemy-trino/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}