Skip to main content

Test SQL files using DuckDB and CSV fixtures

Project description

SQLTest

A command-line tool to test SQL queries using DuckDB and CSV fixtures.

License: MIT

Installation

pip install .

Usage

The sqltest command looks for SQL files in your project and tests them against fixture data.

# Run all SQL tests with default settings
sqltest

# Specify a custom test directory
sqltest --test-dir=custom/tests/path

# Run with verbose output
sqltest --verbose

The verbose output now includes enhanced error highlighting with color coding:

  • Green for matching values and passed tests
  • Red for mismatched values and failed tests
  • Yellow for structural differences

Key features of the enhanced output:

  • Vertical alignment of differences for improved visual clarity
  • Row-by-row comparison that clearly shows which specific rows have issues
  • Color-coded output to quickly identify discrepancies
  • Detailed column analysis to understand patterns in the data

This makes it easier to identify and fix issues in your SQL queries, especially when dealing with complex datasets.

Test Structure

  • Place your SQL files anywhere in your repository
  • Create a test directory (default: tests/sqltest)
  • For each SQL file, create a subdirectory with the same name (without extension)
  • Within each subdirectory, place:
    • output.csv: The expected output of your SQL query
    • Other CSV files named after tables referenced in your SQL query

Example Structure

/your-project
  /some-dir
    query1.sql
    query2.sql
  /tests
    /sqltest
      /query1
        customers.csv     # Table data
        products.csv      # Table data
        output.csv        # Expected query result
      /query2
        table1.csv        # Table data
        output.csv        # Expected query result

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

If you want to run the examples, just do

cd examples

sqltest

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

sqltesty-0.1.4.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqltesty-0.1.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file sqltesty-0.1.4.tar.gz.

File metadata

  • Download URL: sqltesty-0.1.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sqltesty-0.1.4.tar.gz
Algorithm Hash digest
SHA256 db0ea82ec7f7a5b350f972da8952db18851943311d592e1c1fd07f22cdb4e1b6
MD5 51db21639bb6e1a8eb080da078cbe212
BLAKE2b-256 1a07a11587717a47c32acabf086c0b71c746c1ca8cdf8e0069566e865eebe898

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqltesty-0.1.4.tar.gz:

Publisher: cd.yml on PascalStehling/sqltesty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqltesty-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sqltesty-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sqltesty-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 23dcf0999b0fdf8a6aa9f47e5b0c9b3e7633ac415cd9b9b773cb7e3d204191e6
MD5 d2aa8406144d7efec3f768aea6b0c40b
BLAKE2b-256 db39faee5f4c4ac26b94b03b1d24121a05bf355e5b9e3a0e89bd614125dc78b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqltesty-0.1.4-py3-none-any.whl:

Publisher: cd.yml on PascalStehling/sqltesty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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