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.2.0.tar.gz (11.3 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.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sqltesty-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ba426193584c8637a2214aa9b2ef60a55254ea3891884da9a0bd505e0170b3a2
MD5 0d6db764b54cea8109ff8a30bb1403a1
BLAKE2b-256 88318ac609054eecdd0aa24e4067cf20f33ffc3f749289712e90697ac0ac18ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqltesty-0.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: sqltesty-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2115c9bc71808a9356c9b6ec989a1e37fbc3d1dc0991fe86dbce1765e2b41d0f
MD5 8feab0a059eff0105c1d3b935d6d19d9
BLAKE2b-256 9bbaf255014892a177a85ba398b4c1a3167c794ee8ffc6c61be029c8b25d5a54

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqltesty-0.2.0-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