This connector allows to connect to a SQL Server database and execute SQL queries.

Requirements

ODBC Driver 18 must be installed on the executing computer.

Connection configuration

Password mode

Definition

NameMandatoryDefaultDescription
modenopasswordChange the connection mode. Can be "password" or "connectionstring". "connectionstring" mode allow to use a custom connection string.
hostnameyesTarget host name
databaseyesTarget database name
usernameyesSql user name
passwordyesSql user password
portno1433Port to use by the connection
trustservercertificatenofalseTrust the server ssl connection
encryptnoyesEncrypt the connection
drivernoODBC Driver 18 for SQL ServerDriver to use by the connection
⚠️ it's highly recommended to use a parameter to pass the password value

Example

mssql_example:
  type: mssql
  hostname: ploosh.database.windows.net
  database: SampleDB
  username: sa_ploosh
  password: $var.saplooshpassword 

Definition

Connection string mode

NameMandatoryDefaultDescription
modenopasswordUse "connectionstring" value to use custom connectionstring
connection_stringyesConnection string use to access in the database. Refer to SQLAlchemy documentation to get the accepted format

Example

mssql_example:
  type: mssql
  mode: connection_string
  connection_string: "mssql+pyodbc://ploosh01:1433/SampleDB?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes&authentication=ActiveDirectoryIntegrated"

Test case configuration

Definition

NameMandatoryDefaultDescription
connectionyesThe connection to use
queryyesThe query to execute to the database

Example

Example SQL Server:
  source:
    connection: mssql_example
    type: mssql
    query: | 
        select * 
            from [rh].[employees]
            where [hire_date] < '2000-01-01'
  expected:
    type: csv
    path: data/employeesbefore2000.csv