{"id":8443,"library":"presto-client","title":"Presto Client (Renamed to Trino Python Client)","description":"The `presto-client` library, currently at version 0.303.0, has been renamed and superseded by the `trino-python-client` project, which is available on PyPI as the `trino` package. While `presto-client` exists, it is largely a stub advising migration. Trino (formerly PrestoSQL) is a distributed SQL query engine for big data analytics. The actively maintained `trino` library provides a DBAPI 2.0 compliant client, with current versions released frequently, often monthly or bi-monthly, reflecting active development and maintenance.","status":"renamed","version":"0.303.0","language":"en","source_language":"en","source_url":"https://github.com/trinodb/trino-python-client","tags":["database","trino","presto","sql","client","analytics"],"install":[{"cmd":"pip install trino","lang":"bash","label":"Install the actively maintained Trino client"}],"dependencies":[{"reason":"Required for HTTP communication with the Trino server.","package":"requests"},{"reason":"Optional: Provides faster decompression for query results.","package":"lz4","optional":true},{"reason":"Optional: Provides faster decompression for query results.","package":"zstd","optional":true}],"imports":[{"note":"The original 'presto-client' package imported under 'presto'. The current, actively maintained package is 'trino'.","wrong":"from presto.dbapi import connect","symbol":"connect","correct":"from trino.dbapi import connect"},{"note":"Exception class names have also changed from 'Presto...' to 'Trino...'.","wrong":"from presto.exceptions import PrestoQueryError","symbol":"TrinoQueryError","correct":"from trino.exceptions import TrinoQueryError"}],"quickstart":{"code":"import trino\nimport os\n\n# Connect to Trino using environment variables for host, port, etc.\n# Default to common local settings if env vars are not set.\nconn = trino.dbapi.connect(\n    host=os.environ.get('TRINO_HOST', 'localhost'),\n    port=int(os.environ.get('TRINO_PORT', '8080')),\n    user=os.environ.get('TRINO_USER', 'python_client'),\n    catalog=os.environ.get('TRINO_CATALOG', 'system'),\n    schema=os.environ.get('TRINO_SCHEMA', 'runtime'),\n    http_scheme=os.environ.get('TRINO_HTTP_SCHEME', 'http'),\n    auth=trino.auth.BasicAuthentication(\n        username=os.environ.get('TRINO_USERNAME', ''),\n        password=os.environ.get('TRINO_PASSWORD', '')\n    ) if os.environ.get('TRINO_USERNAME') else None,\n)\n\nwith conn.cursor() as cur:\n    cur.execute(\"SELECT node_id, uri FROM nodes LIMIT 5\")\n    for row in cur.fetchall():\n        print(row)\n","lang":"python","description":"This quickstart demonstrates how to connect to a Trino cluster, execute a simple query, and fetch results using the DBAPI 2.0 interface. It uses environment variables for configuration to avoid hardcoding sensitive information. The `with conn.cursor()` syntax is supported from version 0.334.0 onwards."},"warnings":[{"fix":"Uninstall `presto-client` (`pip uninstall presto-client`), then install the new client (`pip install trino`). Update all import statements from `import presto` to `import trino`.","message":"The `presto-client` library has been officially renamed and superseded by the `trino` package. Continuing to use `presto-client` is not recommended due to lack of updates and potential incompatibilities with newer Trino servers.","severity":"breaking","affected_versions":"All versions of `presto-client`."},{"fix":"Always use `pip install trino` for installation and `import trino` in your Python code.","message":"The PyPI project `trino-python-client` (which is the successor to `presto-client`) is installed using the package name `trino` (`pip install trino`), and imported as `import trino`. Attempting to install or import using `trino-python-client` directly will fail.","severity":"gotcha","affected_versions":"All versions of the `trino` package."},{"fix":"Set `http_scheme='https'` in your `trino.dbapi.connect` call. If using self-signed certificates, you may need to pass `verify=False` (use with extreme caution in production) or provide a `cert` path, e.g., `cert='/path/to/my_ca.pem'`.","message":"Connecting to a Trino server over HTTPS (SSL/TLS) requires explicit configuration for `http_scheme` and potentially certificate verification.","severity":"gotcha","affected_versions":"All versions of `trino`."},{"fix":"Install optional dependencies using `pip install \"trino[lz4]\"` or `pip install \"trino[zstd]\"` (or both with `\"trino[lz4,zstd]\"`). The client will automatically use them if available.","message":"Performance for fetching large query results can be significantly improved by installing optional compression libraries, `lz4` or `zstd`.","severity":"gotcha","affected_versions":"All versions of `trino`."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change all import statements in your code from `import presto` or `from presto...` to `import trino` or `from trino...`.","cause":"You have installed the new `trino` package but your code is still trying to import from the old `presto` package name.","error":"ModuleNotFoundError: No module named 'presto'"},{"fix":"The correct package to import is `trino`. Change your import statement to `import trino` (after ensuring you've installed it with `pip install trino`).","cause":"You are trying to import the Python package using its PyPI project name (`trino-python-client`), which contains a hyphen and is not the correct importable package name.","error":"ModuleNotFoundError: No module named 'trino-python-client'"},{"fix":"Verify the `user`, `catalog`, and `schema` parameters in your `trino.dbapi.connect` call. Ensure the user specified has the required privileges to access the queried table/schema on the Trino cluster.","cause":"The Trino server denied the query, usually because the connected user lacks necessary permissions or the specified catalog/schema is incorrect or inaccessible.","error":"trino.exceptions.TrinoQueryError: Server error: io.trino.spi.security.AccessDeniedException: Cannot select from table system.runtime.nodes"},{"fix":"If your Trino server uses HTTPS, ensure `http_scheme='https'` in your connection parameters. If you are using self-signed certificates, you may need to provide the certificate path via the `cert` parameter or (less securely) set `verify=False`.","cause":"The client failed to establish a secure (HTTPS) connection to the Trino server. This can be due to `http_scheme` not being set to `'https'`, an untrusted server certificate, or an incorrect certificate path.","error":"requests.exceptions.SSLError: HTTPSConnectionPool(...) Max retries exceeded with url: /v1/statement"}]}