Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defer_connect config to allow eagerly verifying connection #394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 2, 2023

  1. Add defer_connect config to allow eagerly verifying connection

    This commit adds a new connection parameter `defer_connect` which can be
    set to False to force creating a connection when `trino.dbapi.connect`
    is called. Any connection errors as a result of that get rewrapped into
    `trino.exceptions.TrinoConnectionError`.
    
    By default `defer_connect` is set to `True` so users can explicitly call
    `trino.dbapi.Connection.connect` to do the connection check.
    
    This doesn't end up actually executing a query on the server because
    after the initial POST request the nextUri in the response is not
    followed which leaves the query in QUEUED state. This is not documented
    in the Trino REST API but the server does behave like this today. The
    benefit is that we can very cheaply verify if the connection is valid
    without polluting the server's query history or adding queries to queue.
    
    Some unit tests today relied on the lazy connection behaviour so they
    have been adjusted accrodingly.
    Shaheer-rossoneri14 committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    e764a6a View commit details
    Browse the repository at this point in the history