SQL Server

This connector is used to query a Microsoft SQL Server database using SQL.

Requirement: ODBC Driver 18 for SQL Server must be installed on the system.
>
Installation guides: Windows | Linux | macOS

Connection configuration

Two connection modes are available: password and connection_string.

Password mode

NameMandatoryDefaultDescription
modenopasswordConnection mode: password or connectionstring
hostnameyesServer hostname or IP address
databaseyesDatabase name
usernameyesUsername
passwordyesPassword
portno1433Port number
encryptnotrueEnable connection encryption
trustserver_certificatenofalseTrust the server certificate without validation
drivernoODBC Driver 18 for SQL ServerODBC driver name

Connection string mode

NameMandatoryDefaultDescription
modeyesMust be connectionstring
connectionstringyesSQLAlchemy connection string

Example (password mode)

connections:
  mssql_connection:
    type: mssql
    hostname: my-server.database.windows.net
    database: my_database
    username: my_user
    password: $var.mssql_password
    port: 1433
    encrypt: true
    trustservercertificate: false

Example (connection string mode)

connections:
  mssql_connection:
    type: mssql
    mode: connection_string
    connectionstring: mssql+pyodbc:///?odbcconnect=Driver={ODBC Driver 18 for SQL Server};Server=myserver;Database=mydb;Uid=myuser;Pwd=mypassword;Encrypt=yes;

Test case configuration

NameMandatoryDefaultDescription
queryyesSQL query to execute

Example

Example SQL Server:
  source:
    type: mssql
    connection: mssql_connection
    query: |
      SELECT *
      FROM employees
      WHERE hire_date < '2000-01-01'
  expected:
    type: csv
    path: data/employeesbefore2000.csv

Requirements