SqlServerConnector¶
SQL Server JDBC source connector.
- class scamander.sources.sqlserver_connector.SqlServerConnector(config: Config, *args, **kwargs)¶
Bases:
SourceSource connector that reads a SQL Server table or query into a Spark DataFrame via JDBC.
Expects the
Configobject to carry aSqlSourceOptionsinstance underconfig.source.options. Eitheroptions.tableoroptions.querymust be set to identify the data source.- Parameters:
config (Config) – Validated configuration object containing SQL Server connection details under
config.source.options.spark (SparkSession) – An active Spark session used to execute the JDBC read.
- Raises:
ValueError – If
config.source.optionsis not aSqlSourceOptionsinstance.ValueError – If neither
options.tablenoroptions.queryis provided.
- connect() DataFrame¶
Establishes a JDBC connection to SQL Server and returns data as a Spark DataFrame.
When
options.queryis set it is used as the data source (wrapped in a subquery for JDBC compatibility); otherwiseoptions.tableis used directly.The connection is built from
host,port,database,username,password,encrypt, andtrust_server_certificatefromSqlSourceOptions.- Returns:
A Spark DataFrame backed by the SQL Server source.
- Return type:
DataFrame