awswrangler.sqlserver.connect

awswrangler.sqlserver.connect(connection: Optional[str] = None, secret_id: Optional[str] = None, catalog_id: Optional[str] = None, dbname: Optional[str] = None, odbc_driver_version: int = 17, boto3_session: Optional[boto3.session.Session] = None, timeout: Optional[int] = 0)Any

Return a pyodbc connection from a Glue Catalog Connection.

https://github.com/mkleehammer/pyodbc

Parameters
  • connection (Optional[str]) – Glue Catalog Connection name.

  • secret_id (Optional[str]:) – Specifies the secret containing the version 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]) – Optional database name to overwrite the stored one.

  • odbc_driver_version (int) – Major version of the OBDC Driver version that is installed and should be used.

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

  • 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 forwarded to pyodbc. https://github.com/mkleehammer/pyodbc/wiki/The-pyodbc-Module#connect

Returns

pyodbc connection.

Return type

pyodbc.Connection

Examples

>>> import awswrangler as wr
>>> con = wr.sqlserver.connect(connection="MY_GLUE_CONNECTION", odbc_driver_version=17)
>>> with con.cursor() as cursor:
>>>     cursor.execute("SELECT 1")
>>>     print(cursor.fetchall())
>>> con.close()