Test SQL files using DuckDB and CSV fixtures
Project description
SQLTest
A command-line tool to test SQL queries using DuckDB and CSV fixtures.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba426193584c8637a2214aa9b2ef60a55254ea3891884da9a0bd505e0170b3a2
|
|
| MD5 |
0d6db764b54cea8109ff8a30bb1403a1
|
|
| BLAKE2b-256 |
88318ac609054eecdd0aa24e4067cf20f33ffc3f749289712e90697ac0ac18ad
|
Provenance
The following attestation bundles were made for sqltesty-0.2.0.tar.gz:
Publisher:
cd.yml on PascalStehling/sqltesty
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqltesty-0.2.0.tar.gz -
Subject digest:
ba426193584c8637a2214aa9b2ef60a55254ea3891884da9a0bd505e0170b3a2 - Sigstore transparency entry: 206631750
- Sigstore integration time:
-
Permalink:
PascalStehling/sqltesty@f8c9f38853c925d1d0be17c248523e9e6b964352 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PascalStehling
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@f8c9f38853c925d1d0be17c248523e9e6b964352 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2115c9bc71808a9356c9b6ec989a1e37fbc3d1dc0991fe86dbce1765e2b41d0f
|
|
| MD5 |
8feab0a059eff0105c1d3b935d6d19d9
|
|
| BLAKE2b-256 |
9bbaf255014892a177a85ba398b4c1a3167c794ee8ffc6c61be029c8b25d5a54
|
Provenance
The following attestation bundles were made for sqltesty-0.2.0-py3-none-any.whl:
Publisher:
cd.yml on PascalStehling/sqltesty
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqltesty-0.2.0-py3-none-any.whl -
Subject digest:
2115c9bc71808a9356c9b6ec989a1e37fbc3d1dc0991fe86dbce1765e2b41d0f - Sigstore transparency entry: 206631751
- Sigstore integration time:
-
Permalink:
PascalStehling/sqltesty@f8c9f38853c925d1d0be17c248523e9e6b964352 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PascalStehling
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@f8c9f38853c925d1d0be17c248523e9e6b964352 -
Trigger Event:
push
-
Statement type: