awswrangler.redshift.connect_temp¶
- awswrangler.redshift.connect_temp(cluster_identifier: str, user: str, database: Optional[str] = None, duration: int = 900, auto_create: bool = True, db_groups: Optional[List[str]] = None, boto3_session: Optional[Session] = None, ssl: bool = True, timeout: Optional[int] = None, max_prepared_statements: int = 1000, tcp_keepalive: bool = True, **kwargs: Any) 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, optional) – The name of a database user.
database (str, optional) – Database name. If None, the default Database is used.
duration (int, optional) – The number of seconds until the returned temporary password expires. Constraint: minimum 900, maximum 3600. Default: 900
auto_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], optional) – 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 (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 (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. https://github.com/aws/amazon-redshift-python-driver
max_prepared_statements (int) – This parameter is forward to redshift_connector. https://github.com/aws/amazon-redshift-python-driver
tcp_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=’…’
- Returns
redshift_connector connection.
- Return type
redshift_connector.Connection
Examples
>>> import awswrangler as wr >>> con = wr.redshift.connect_temp(cluster_identifier="my-cluster", user="test") >>> with con.cursor() as cursor: >>> cursor.execute("SELECT 1") >>> print(cursor.fetchall()) >>> con.close()