trinodb / trino-python-client

Python client for Trino
Apache License 2.0
327 stars 163 forks source link

Having no keyring backends should be treated as no keyring module and fall back to using memory-based cache #431

Closed gerilya closed 7 months ago

gerilya commented 9 months ago

Expected behavior

If an attempt to load keyring module fails, there is a fall back to _OAuth2TokenInMemoryCache. I think no backends or having keyring.backends.null.Keyring backend should be treated the same way. Using keyring.backends.null.Keyring backend is the recommended way to disable keyring. See Disabling Keyring at https://pypi.org/project/keyring/

Actual behavior

When there is keyring package installed but there are no available backends, the following error is generated:

Although keyring module is installed no backend has been detected, check https://pypi.org/project/keyring/ for more information.

Steps To Reproduce

Run the following code on Sagemaker notebook instance:

import trino

connect = trino.dbapi.connect(
                              host=config['HOST'],
                              port=config['PORT'],
                              http_scheme=config['PROTOCOL'],
                              auth=trino.auth.OAuth2Authentication(),
                              user=config['USERNAME'],
                              )
cursor=connect.cursor()
query="some query"
cursor.execute(query)

Log output

[ 2023-12-14T09:53:41.370244 | Although keyring module is installed no backend has been detected, check https://pypi.org/project/keyring/ for more information. ]

Operating System

AWS Sagemaker Notebook

Trino Python client version

0.327.0

Trino Server version

can't connect - not relevant

Python version

Python 3.10.13

Are you willing to submit PR?

hashhar commented 7 months ago

@hovaesco can this be closed after #435?

hovaesco commented 7 months ago

@hashhar Yes.

hovaesco commented 7 months ago

Resolved by https://github.com/trinodb/trino-python-client/pull/435