connect(connection: Optional[str] = None, secret_id: Optional[str] = None, catalog_id: Optional[str] = None, dbname: Optional[str] = None, boto3_session: Optional[boto3.session.Session] = None, ssl_context: Optional[Dict[Any, Any]] = None, timeout: Optional[int] = None, tcp_keepalive: bool = True) → pg8000.legacy.Connection¶
Return a pg8000 connection from a Glue Catalog Connection.
connection (Optional[str]) – Glue Catalog Connection name.
dbname (Optional[str]) – Optional database name to overwrite the stored one.
ssl_context (Optional[Dict]) – This governs SSL encryption for TCP/IP sockets. This parameter is forward to pg8000. https://github.com/tlocke/pg8000#functions
timeout (Optional[int]) – 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 pg8000. https://github.com/tlocke/pg8000#functions
tcp_keepalive (bool) – If True then use TCP keepalive. The default is True. This parameter is forward to pg8000. https://github.com/tlocke/pg8000#functions
- Return type
>>> import awswrangler as wr >>> con = wr.postgresql.connect("MY_GLUE_CONNECTION") >>> with con.cursor() as cursor: >>> cursor.execute("SELECT 1") >>> print(cursor.fetchall()) >>> con.close()