How to execute SQL against CSV resources

Assuming there is a project containing VIVIDUS-based tests (e.g. VIVIDUS Starter) and the goal is to execute SQL queries against CSV resources to get the various subsets of the data.

  1. Add the required dependencies (CSV and DB plugins, CSV driver) to the project build.gradle

    implementation(group: 'org.vividus', name: 'vividus-plugin-csv', version: '0.3.7-SNAPSHOT')
    implementation(group: 'org.vividus', name: 'vividus-plugin-db', version: '0.3.7-SNAPSHOT')
    implementation(group: 'com.github.simoc', name: 'csvjdbc', version: 'd939a2f344')
  2. Configure connection to the CSV resources


    driver-class-name should be the same for all CSV connections. url includes the mandatory path to CSV resources and may also contain a set of options configuring CSV parsing, e.g.:

  3. Use the configured connection to execute SQL

    Example 1. Execute SQL against CSV
    When I execute SQL query `
    SELECT * FROM capitals
    ` against `csv-data` and save result to scenario variable `csv-records`
    Then `${csv-records}` matching rows using `country` from `csv-data` is equal to data from:
    |country |capital |population |
    |Belarus |Minsk   |1975000    |

    where capitals is the name of CSV resource (the full resource path is path/to/csv/data/capitals.csv).

    The complete guide on SQL syntax and supported functions can be found in CSV Driver documentation.