ODBC

This connector is used to query any database accessible via an ODBC driver.

Connection configuration

Two connection modes are available: DSN and connection_string.

DSN mode

NameMandatoryDefaultDescription
modenoDSNConnection mode: DSN or connectionstring
DSNyesData Source Name configured on the system
autocommitnotrueEnable auto-commit
usecredentialsnofalseWhether to pass username/password
usernoUsername (when usecredentials is true)
passwordnoPassword (when use_credentials is true)
encodingnoUTF-8Encoding for the connection

Connection string mode

NameMandatoryDefaultDescription
modeyesMust be connectionstring
connectionstringyesODBC connection string
auto_commitnotrueEnable auto-commit
encodingnoUTF-8Encoding for the connection

Example (DSN mode)

connections:
  odbc_connection:
    type: odbc
    DSN: mydatasource
    use_credentials: true
    user: my_user
    password: $var.odbc_password

Example (connection string mode)

connections:
  odbc_connection:
    type: odbc
    mode: connection_string
    connection_string: "Driver={ODBC Driver 18 for SQL Server};Server=myserver;Database=mydb;Uid=myuser;Pwd=mypassword;"

Test case configuration

NameMandatoryDefaultDescription
queryyesSQL query to execute

Example

Example ODBC:
  source:
    type: odbc
    connection: odbc_connection
    query: |
      SELECT *
      FROM employees
      WHERE department = 'Engineering'
  expected:
    type: csv
    path: data/expected_engineers.csv

Requirements

  • pip install pyodbc (included in ploosh full installation)
  • An ODBC driver installed and a DSN configured on the system