Skip to content

(enhancement): Enable passing kwargs to redshift_connector.connect #1467

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

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions awswrangler/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def connect(
timeout: Optional[int] = None,
max_prepared_statements: int = 1000,
tcp_keepalive: bool = True,
**kwargs: Any,
) -> redshift_connector.Connection:
"""Return a redshift_connector connection from a Glue Catalog or Secret Manager.

Expand All @@ -455,23 +456,23 @@ def connect(

Parameters
----------
connection : Optional[str]
connection : str, optional
Glue Catalog Connection name.
secret_id : Optional[str]:
Specifies the secret containing the connection details that you want to retrieve.
You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.
catalog_id : str, optional
The ID of the Data Catalog.
If none is provided, the AWS account ID is used by default.
dbname : Optional[str]
dbname : str, optional
Optional database name to overwrite the stored one.
boto3_session : boto3.Session(), optional
Boto3 Session. The default boto3 session will be used if boto3_session receive None.
ssl : bool
This governs SSL encryption for TCP/IP sockets.
This parameter is forward to redshift_connector.
https://github.com/aws/amazon-redshift-python-driver
timeout : Optional[int]
timeout : int, optional
This is the time in seconds before the connection to the server will time out.
The default is None which means no timeout.
This parameter is forward to redshift_connector.
Expand All @@ -483,6 +484,9 @@ def connect(
If True then use TCP keepalive. The default is True.
This parameter is forward to redshift_connector.
https://github.com/aws/amazon-redshift-python-driver
**kwargs : Any
Forwarded to redshift_connector.connect.
e.g. is_serverless=True, serverless_acct_id='...', serverless_work_group='...'

Returns
-------
Expand Down Expand Up @@ -527,6 +531,7 @@ def connect(
timeout=timeout,
max_prepared_statements=max_prepared_statements,
tcp_keepalive=tcp_keepalive,
**kwargs,
)


Expand All @@ -542,6 +547,7 @@ def connect_temp(
timeout: Optional[int] = None,
max_prepared_statements: int = 1000,
tcp_keepalive: bool = True,
**kwargs: Any,
) -> redshift_connector.Connection:
"""Return a redshift_connector temporary connection (No password required).

Expand Down Expand Up @@ -571,7 +577,7 @@ def connect_temp(
This governs SSL encryption for TCP/IP sockets.
This parameter is forward to redshift_connector.
https://github.com/aws/amazon-redshift-python-driver
timeout : Optional[int]
timeout : int, optional
This is the time in seconds before the connection to the server will time out.
The default is None which means no timeout.
This parameter is forward to redshift_connector.
Expand All @@ -583,6 +589,9 @@ def connect_temp(
If True then use TCP keepalive. The default is True.
This parameter is forward to redshift_connector.
https://github.com/aws/amazon-redshift-python-driver
**kwargs : Any
Forwarded to redshift_connector.connect.
e.g. is_serverless=True, serverless_acct_id='...', serverless_work_group='...'

Returns
-------
Expand Down Expand Up @@ -623,6 +632,7 @@ def connect_temp(
max_prepared_statements=max_prepared_statements,
tcp_keepalive=tcp_keepalive,
db_groups=db_groups,
**kwargs,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def redshift_con():


def test_connection():
wr.redshift.connect("aws-data-wrangler-redshift", timeout=10).close()
wr.redshift.connect("aws-data-wrangler-redshift", timeout=10, force_lowercase=False).close()


def test_read_sql_query_simple(databases_parameters):
Expand Down