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.0.tar.gz (10.0 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.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqltesty-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 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.0.tar.gz
Algorithm Hash digest
SHA256 f62800893827c8300554d32bba7af5a016af65baf861ba9dc826c4eab14e4710
MD5 c9302e38b7ed46d1b315b54664e9681d
BLAKE2b-256 b29e22fa373e98d137d5424cfd0e8f0c7af813ca8966e216b17bc266b19c22c5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sqltesty-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a983a2ceb29ca0958b03ddbabcdd5b152831f37b61057e4eff1351a5488265b7
MD5 4b2d5741a9f60e540469b2198c326059
BLAKE2b-256 a46d3464862da3a09780e24d7520bb3439a8b5d789d7b58ce1e2d68faa79940d

See more details on using hashes here.

Provenance

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