awswrangler.redshift.connect_temp¶
- awswrangler.redshift.connect_temp(cluster_identifier: str, user: str, database: str | None = None, duration: int = 900, auto_create: bool = True, db_groups: list[str] | None = None, boto3_session: Session | None = None, ssl: bool = True, timeout: int | None = None, max_prepared_statements: int = 1000, tcp_keepalive: bool = True, **kwargs: Any) redshift_connector.Connection ¶
Return a redshift_connector temporary connection (No password required).
https://github.com/aws/amazon-redshift-python-driver
- Parameters:
cluster_identifier (
str
) – The unique identifier of a cluster. This parameter is case sensitive.user (
str
) – The name of a database user.database (
str
|None
) – Database name. If None, the default Database is used.duration (
int
) – The number of seconds until the returned temporary password expires. Constraint: minimum 900, maximum 3600. Default: 900auto_create (
bool
) – Create a database user with the name specified for the user named in user if one does not exist.db_groups (
list
[str
] |None
) – A list of the names of existing database groups that the user named in user will join for the current session, in addition to any group memberships for an existing user. If not specified, a new user is added only to PUBLIC.boto3_session (
Session
|None
) – The default boto3 session will be used if boto3_session isNone
.ssl (
bool
) – This governs SSL encryption for TCP/IP sockets. This parameter is forward to redshift_connector. https://github.com/aws/amazon-redshift-python-drivertimeout (
int
|None
) – 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. https://github.com/aws/amazon-redshift-python-drivermax_prepared_statements (
int
) – This parameter is forward to redshift_connector. https://github.com/aws/amazon-redshift-python-drivertcp_keepalive (
bool
) – 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=’…’
- Return type:
Connection
- Returns:
redshift_connector
connection.
Examples
>>> import awswrangler as wr >>> with wr.redshift.connect_temp(cluster_identifier="my-cluster", user="test") as con: ... with con.cursor() as cursor: ... cursor.execute("SELECT 1") ... print(cursor.fetchall())