SQLServerDatasource
Adds a SQL Server datasource to the data context.
Parameters
Name Description name
The name of this SQL Server datasource.
host
The environment where the Microsoft SQL Server engine is installed and running, for example "sql-server.example.com" for self-hosted Microsoft SQL Server.
database
The name of the Microsoft SQL Server database where the data you want to validate is stored.
schema
The name of the Microsoft SQL Server schema where the data you want to validate is stored.
port
The port configured for your Microsoft SQL Server instance, typically 1433.
encrypt
The TLS encryption protocol to use. Accepts the following.
- "Optional" - Establish an encrypted connection if your Microsoft SQL Server instance is configured to force encryption. Otherwise, establish an unencrypted connection.
- "Mandatory" - Require the connection to be encrypted. Validate the server certificate unless "trust_server_certificate" is set to "True". Connection will fail if your Microsoft SQL Server instance does not support TLS. If "trust_server_certificate" is set to "False", connection will fail if the certificate is not valid and publicly trusted.
- "Strict" - Use TDS 8.0 where encryption begins before the TLS handshake. Require the connection to be encrypted and validate the server certificate. Connection will fail if your Microsoft SQL Server instance does not support TLS or the certificate is not valid and publicly trusted.
trust_server_certificate
If you set "encrypt" to "Mandatory", you can set "trust_server_certificate" to "True" to enable using an encrypted connection without a valid publicly trusted server certificate (default is "False"). This lets you, for example, use a self-signed certificate with an encrypted connection.
driver
The name of the ODBC driver your environment uses to connect to Microsoft SQL Server. Common values include the following:
- "ODBC Driver 18 for SQL Server"
- "ODBC Driver 17 for SQL Server"
- "FreeTDS"
authentication
Accepts "SQL Server" or "Entra ID". Required credential parameters depend on the authentication method.
username
For "SQL Server" authentication. The username you use to access Microsoft SQL Server.
password
For "SQL Server" authentication. The password you use to access Microsoft SQL Server.
tenant_id
For "Entra ID" authentication. The unique identifier for your organization's instance of Microsoft Entra ID.
client_id
For "Entra ID" authentication. The application ID for your new or existing Entra ID app registration.
client_secret
For "Entra ID" authentication. A new secret key from your Entra ID app registration.
assets
An optional dictionary whose keys are TableAsset or QueryAsset names and whose values are TableAsset or QueryAsset objects.
Adds a query asset to this datasource.
Parameters
Name Description name
The name of this query asset.
query
The SELECT query to selects the data to validate. It must begin with the "SELECT".
batch_metadata
BatchMetadata we want to associate with this DataAsset and all batches derived from it.
Returns
Type Description QueryAsset
The query asset that is added to the datasource. The type of this object will match the necessary type for this datasource. eg, it could be a QueryAsset or a SqliteQueryAsset.
Adds a table asset to this datasource.
- Parameters
name – The name of this table asset.
table_name – The table where the data resides.
schema_name –
The schema that holds the table. Will use the datasource schema if not provided.
Deprecated since version 1.14.0: Pass the schema in your datasource's connection configuration instead.
batch_metadata – BatchMetadata we want to associate with this DataAsset and all batches derived from it.
Returns
Type Description TableAsset
The table asset that is added to the datasource. The type of this object will match the necessary type for this datasource. eg, it could be a TableAsset or a SqliteTableAsset.
Removes the DataAsset referred to by asset_name from internal list of available DataAsset objects.
Parameters
Name Description name
name of DataAsset to be deleted.
Returns the DataAsset referred to by asset_name
Parameters
Name Description name
name of DataAsset sought.
Returns
Type Description great_expectations.datasource.fluent.interfaces._DataAssetT
if named "DataAsset" object exists; otherwise, exception is raised.
class great_expectations.datasource.fluent.SQLServerDatasource(
*,
type: Literal['sql_server'] = 'sql_server',
name: str,
id: Optional[uuid.UUID] = None,
assets: List[Union[great_expectations.datasource.fluent.sql_datasource.TableAsset,
great_expectations.datasource.fluent.sql_datasource.QueryAsset]] = [],
connection_string: Union[great_expectations.datasource.fluent.sql_server_datasource.SQLServerAuthConnectionDetails,
great_expectations.datasource.fluent.sql_server_datasource.EntraIDServicePrincipalAuthConnectionDetails],
create_temp_table: bool = False,
kwargs: Dict[str,
Union[great_expectations.datasource.fluent.config_str.ConfigStr,
Any]] = {}
)
Methods
add_query_asset
add_query_asset(
name: str,
query: str,
batch_metadata: Optional[BatchMetadata] = None
) → QueryAsset
add_table_asset
add_table_asset(
name: str,
table_name: str = '',
schema_name: str | Missing | None = <great_expectations.datasource.fluent.sql_datasource.Missing object>,
batch_metadata: Optional[BatchMetadata] = None
) → TableAsset
delete_asset
delete_asset(
name: str
) → None
get_asset
get_asset(
name: str
) → great_expectations.datasource.fluent.interfaces._DataAssetT