❖ MSSQL
This page describes how to integrate with your Microsoft SQL database.
Installation
To use this feature, please make sure you have installed the bundle with the optional db-mssql dependency. For more information, see the SDV Enterprise Installation docs.
pip install sdv-installer --upgrade
sdv-installer install --package bundle-ai-connectors --options db-mssqlMicrosoft SQL also requires that you have the ODBC Driver installed on your machine. For more information, see instructions from Microsoft for Windows, MacOS, and Linux.
Connector
Create a connector object that interacts with your MSSQL database.
from sdv.io.database import MSSQLConnector
connector = MSSQLConnector()Parameters (None)
Output A connector object that you can use to import data and metadata
Config File
Create a YAML file that corresponds to the database to connect to. You will need separate config files for your source dataset (for importing training data) and a destination dataset (for exporting synthetic data).
The config file has the following structure:
Parameters:
connection: This section defines the database tables you want to connect to. It is common to all traditional, self-managed databases that are not managed by a Cloud vendor.
(required)
host: The network address of the system running the database service. Based on your db setup, this can be a hostname (eg. db.example.com) or an IP address (eg. 10.0.0.1)(required)
port: The network endpoint on the host where the database service listens for client connections. This is a numeric identifier but please provide it as a string.(required)
database_name: A top-level logical container for data and database objects within a database system.(required)
schema_name: A named logical grouping of database objects within a database, used for organization and access control.
auth: This section provides information about your identity, which is required to connect to the database. It is common to all traditional, self-managed databases that are not managed by a Cloud vendor.
(required)
username: The identifier of who is authenticating the connection.(required)
password: A secret credential associated with the username, used to verify its identity during authentication
runtime: This section contains other parameters that come into play during runtime, either when establishing the connection or running additional queries. It is common to all traditional, self-managed databases that are not managed by a Cloud vendor.
connection_timeout: The maximum amount of time a client will wait while attempting to establish a connection to the database before stopping the attempt. This applies when first establishing the connection, not for any subsequent queries or timeouts.(default) Driver and environment dependent, typically between ~10-30 seconds, but potentially unbounded.
options.MSSQLConnector: This section includes information that is specific for MSSQL databases
encrypt: Specifies whether the connection between the client (SDV) and the database server is encrypted.(default)
true: Encrypt all data transmitted over the network between the client and server, including authentication credentials and query/result traffic.false: Do not encrypt
trust_server_certificate: In the case that encryption is turned on, this parameter controls whether the client (SDV) verifies the identity of the database server when establishing an encrypted connection.(default)
false: The client (SDV) validates the certificate (recommended, secure)true: The client (SDV) skips validation. Encryption still happens, but identity is not verified.
max_pool_size: The maximum number of database connections that the application (SDV) is allowed to keep open at the same time.(default) 100
Setting Your Config File
Use the set_import_config and set_export_config functions to add your config YAML file to your connector.
Use the connector to create metadata, import a subset of training data, and export synthetic data. For more information, see the Usage API.
FAQ
Last updated