Skip to main content

simple data validation

Project description

data_check

data_check is a simple data validation tool. In its most basic form it will execute SQL queries and compare the results against CSV or Excel files. But there are more advanced features:

Features

  • CSV checks: compare SQL queries against CSV files
  • Excel support: Use Excel (xlsx) instead of CSV
  • multiple environments (databases) in the configuration file
  • populate tables from CSV files
  • execute any SQL files on a database
  • more complex pipelines
  • run any script/command (via pipelines)
  • simplified checks for empty datasets and full table comparison
  • lookups to reuse the same data in multiple queries

Database support

data_check should work with any database that works with SQLAlchemy. Currently data_check is tested against PostgreSQL, MySQL, SQLite, Oracle and Microsoft SQL Server.

Quickstart

You need Python 3.7.1 or above to run data_check. The easiest way to install data_check is via pipx:

pipx install data-check

The data_check Git repository is also a sample data_check project. Clone the repository, switch to the folder and run data_check:

git clone git@github.com:andrjas/data_check.git
cd data_check/example
data_check

This will run the tests in the checks folder using the default connection as set in data_check.yml.

See the documentation how to install data_check in different environments with additional database drivers and other usages of data_check.

Project layout

data_check has a simple layout for projects: a single configuration file and a folder with the test files. You can also organize the test files in subfolders.

data_check.yml    # The configuration file
checks/           # Default folder for data tests
    some_test.sql # SQL file with the query to run against the database
    some_test.csv # CSV file with the expected result
    subfolder/    # Tests can be nested in subfolders

CSV checks

This is the default mode when running data_check. data_check expects a SQL file and a CSV file. The SQL file will be executed against the database and the result is compared with the CSV file. If they match, the test is passed, otherwise it fails.

Pipelines

If data_check finds a file named data_check_pipeline.yml in a folder, it will treat this folder as a pipeline check. Instead of running CSV checks it will execute the steps in the YAML file.

Example project with a pipeline:

data_check.yml
checks/
    some_test.sql                # this test will run in parallel to the pipeline test
    some_test.csv
    sample_pipeline/
        data_check_pipeline.yml  # configuration for the pipeline
        data/
            my_schema.some_table.csv       # data for a table
        data2/
            some_data.csv        # other data
        some_checks/             # folder with CSV checks
            check1.sql
            check1.csl
            ...
        run_this.sql             # a SQL file that will be executed
        cleanup.sql
    other_pipeline/              # you can have multiple pipelines that will run in parallel
        data_check_pipeline.yml
        ...

The file sample_pipeline/data_check_pipeline.yml can look like this:

steps:
    # this will truncate the table my_schema.some_table and load it with the data from data/my_schema.some_table.csv
    - load_tables: data
    # this will execute the SQL statement in run_this.sql
    - sql_file: run_this.sql
    # this will append the data from data2/some_data.csv to my_schema.other_table
    - load:
        file: data2/some_data.csv
        table: my_schema.other_table
        load_mode: append
    # this will run a python script and pass the connection name
    - cmd: "python3 /path/to/my_pipeline.py --connection {{CONNECTION}}"
    # this will run the CSV checks in the some_checks folder
    - check: some_checks

Pipeline checks and simple CSV checks can coexist in a project.

Documentation

See the documentation how to setup data_check, how to create a new project and more options.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_check-0.11.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

data_check-0.11.0-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file data_check-0.11.0.tar.gz.

File metadata

  • Download URL: data_check-0.11.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.2 Linux/5.10.60.1-microsoft-standard-WSL2

File hashes

Hashes for data_check-0.11.0.tar.gz
Algorithm Hash digest
SHA256 7ace7de5f13121669c68a19df3d6e00094654105e80261dfdb3eeb8919e899d5
MD5 b55a46ea9713627eab25537b5f55c50d
BLAKE2b-256 8edd16e0c681309b7c6f0f2d19ddd2bebc5c53ad7d1cfe2594aa3e6ccdd5fc5f

See more details on using hashes here.

File details

Details for the file data_check-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: data_check-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.2 Linux/5.10.60.1-microsoft-standard-WSL2

File hashes

Hashes for data_check-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24a3dfe5ac1772d5fd0096dc58835a921f6cc57ab06e60f5549e487399da6cb8
MD5 1633bceca50ba4ebbbdb8ea3405d0a90
BLAKE2b-256 d813d3ea0366ab5c3c8586cd2e39aed7af9ab4a5b57872f27a7d2fc6e35ee246

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page