Share via


FabricSqlConnection Class

This class is used to connect to resources that supply SQL connection strings.

A User Data Function with a parameter of this type must be decorated with connection (see the example under Remarks).

Don't worry about using the constructor to create an instance of this class. Fabric will automatically create it for you (as long as you follow the steps within Remarks).

Constructor

FabricSqlConnection(alias_name: str, endpoints: Dict[str, Dict[str, str]])

Parameters

Name Description
alias_name
Required
str

The alias for the data source being connected to, configured in the portal.

endpoints
Required

The different endpoints for the data source.

Remarks

Note

If you want to connect to a Lakehouse SQL endpoint, that should be done through

FabricLakehouseClient instead (and then use it's method connectToSql).

To use this class and have Fabric make the proper connections to your SQL endpoint, you must:

  • Add a data connection in the Connections tab of your User Data Functions on the portal.
  • Add a parameter to your User Data Function with the type 'FabricSqlConnection'.
  • Add the decorator connection to your User Data Function that references the parameter and the alias of the data connection you made.

Methods

connect

Connects to the SQL endpoint. Call this within your function before attempting to query the endpoint.

connect

Connects to the SQL endpoint. Call this within your function before attempting to query the endpoint.

connect() -> Connection