Registry / database / sqlalchemy-trino

sqlalchemy-trino

JSON →
library0.5.0pypypi✓ verified 23d ago

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.

pip install sqlalchemy-trino
INSTALL
IMPORT
SIG · SQLALCHEMY-TRINO
S
sqlalchemy-trino
databasepythonv0.5.0
Install
5.4s avg
Import
624ms
Disk
78MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.0 · 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
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.4s · import 0.624s · 78MB
78MB installed
● package 78MB
Code
Verified usage

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

create_engine
from sqlalchemy import create_engine
The dialect is registered upon package installation; `create_engine` is used from `sqlalchemy` core.

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://`).

import os from sqlalchemy import create_engine, text # NOTE: This library is DEPRECATED. The recommended approach is to use trino-python-client directly. # pip install trino[sqlalchemy] # from sqlalchemy import create_engine # 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')}") # Example using the deprecated sqlalchemy-trino library: # Configure connection details via environment variables or replace directly TRINO_USER = os.environ.get('TRINO_USER', 'test_user') TRINO_HOST = os.environ.get('TRINO_HOST', 'localhost') TRINO_PORT = os.environ.get('TRINO_PORT', '8080') TRINO_CATALOG = os.environ.get('TRINO_CATALOG', 'system') TRINO_SCHEMA = os.environ.get('TRINO_SCHEMA', 'runtime') connection_string = ( f"trino://{TRINO_USER}@{TRINO_HOST}:{TRINO_PORT}/{TRINO_CATALOG}/{TRINO_SCHEMA}" ) try: engine = create_engine(connection_string) with engine.connect() as connection: result = connection.execute(text("SELECT 1")) print("Successfully connected to Trino!") for row in result: print(row) except Exception as e: print(f"Error connecting to Trino: {e}") print("Please ensure Trino is running and connection details are correct.")
Debug
Known issues
breakingThe `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.
fix
Migrate your dependencies from `sqlalchemy-trino` to `trino[sqlalchemy]`. The connection string format remains `trino://...`.
affects: >=0.5.0
gotchaWhen `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.
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`.
affects: sqlalchemy-trino <0.4.1 in conjunction with trino-python-client >=0.307.0
breakingVersion 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`.
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`.
affects: >=0.4.0
gotchaThe default catalog was changed from `hive` to `system` in version 0.3.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.
affects: >=0.3.0
Errors
Common errors & fixes
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:trino
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.
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.
ModuleNotFoundError: No module named 'sqlalchemy_trino'
The user is attempting to directly import a module named `sqlalchemy_trino`, which is not the standard way to use a SQLAlchemy dialect plugin.
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.
sqlalchemy-trino deprecated
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.
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.
DBAPIError: (trino.exceptions.TrinoUserError) TrinoUserError(type=USER_ERROR, name=SCHEMA_NOT_FOUND, message="Schema 'my_schema' not found")
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.
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.
Upgrade
Version history
0.5.0latest on PyPI · released May 5, 2022
Audit
Dependencies
SQLAlchemyrequiredCore SQLAlchemy library for database abstraction.
trinorequiredThe underlying Trino Python client library. Note that `trino` refers to `trino-python-client` on PyPI.
Agent activity
30 hits · last 30 days
node
24
Meta
1
OpenAI (training)
1
Resources
sqlalchemy-trino — pip install sqlalchemy-trino · libregistry