aws / amazon-redshift-python-driver

Redshift Python Connector. It supports Python Database API Specification v2.0.
Apache License 2.0
204 stars 76 forks source link

Fix: force timeouts to integer types #226

Open andrewargeros opened 5 months ago

andrewargeros commented 5 months ago

Description

literally just 2 int() casts for various cases where timeout and idp_response_timeout are read in as strings, but should be integers

Motivation and Context

Since sqlalchemy (and other packages) force url parameters to be passed as strings to redshift_connector, we can run into basic and avoidable issues from this package when connecting to Redshift via SQLAlchemy via the BrowserAzureOAuth2CredentialsProvider method.

Testing

Built package, connected, fixed the bug.

Screenshots (if appropriate)

code to reproduce:

from sqlalchemy import create_engine
engine = create_engine(
"redshift+redshift_connector://{HOST}:5439/{DATABASE}credentials_provider=BrowserAzureOAuth2CredentialsProvider&client_id={CLIENT}&idp_tenant={IDP_TENANT}&scope={SCOPE}/jdbc_login&idp_response_timeout=500&timeout=900000"
)
with engine.connect() as conn:
    result = conn.execute("SELECT 1")
    print(result.fetchone())

Types of changes

Checklist

andrewargeros commented 4 months ago

@Brooke-white not sure what the best way to request review on this is.