Qck 🦆👩💻
Qck (pronounced "quack") is a CLI script to conveniently run DuckDB SQL scripts with support for Jinja templating.
🛠️ Installation
Use pip install qck to install. This will make available the qck
command-line tool.
🚀 Usage
Command Line Interface
The basic usage is to run a SQL file and display results in the terminal:
qck myquery.sql
Key command line options:
--limit N: Limit output to N rows (default: 99 rows)--to-parquet FILE: Save results to a Parquet file--to-csv FILE: Save results to a CSV file--interactive: Open Python shell with query results--verbose, -v: Print the generated SQL queryargs: Pass template parameters as key=value pairs
Examples:
# Limit output to 10 rows
qck myquery.sql --limit 10
# Save to Parquet with verbose output
qck myquery.sql --to-parquet results.parquet -v
# Pass template parameters
qck template.sql date=2024-01-01 region=EU
# Interactive mode
qck myquery.sql --interactive
# Pipe SQL from stdin (use - as filename)
echo "SELECT 42 as answer" | qck -
# With template parameters from stdin
echo "SELECT '{{ name }}' as greeting" | qck - name=World
Python API
You can use Qck programmatically in Python:
from qck import qck
# Basic query execution
rs = qck("myquery.sql")
# With template parameters
rs = qck("template.sql", params={"date": "2024-01-01"})
# Control output limit
rs = qck("myquery.sql", limit=1000)
# Print generated SQL
rs = qck("myquery.sql", print_query=True)
# Access results as pandas DataFrame
df = rs.df()
🖋️ Templating
Qck uses Jinja2 for SQL templating with some special features:
- Parameter substitution:
SELECT *
FROM orders
WHERE date = '{{ date }}'
- Python function imports:
-- Use the special 'import' variable to access Python functions
{% set files = import('glob.glob')('data/*.parquet') %}
{% for file in files %}
SELECT * FROM read_parquet('{{ file }}')
{% if not loop.last %}UNION ALL{% endif %}
{% endfor %}
- Control structures:
SELECT
customer_id,
{% if include_details %}
first_name,
last_name,
email,
{% endif %}
total_orders
FROM customers
- Custom Python functions:
-- Import and use your own functions
{% set helper = import('mymodule.helpers:format_date') %}
SELECT *
FROM events
WHERE date = '{{ helper(date) }}'
The import variable allows importing any Python module or function using:
- Module syntax:
import('module_name') - Function syntax:
import('module:function') - Nested syntax:
import('module.submodule:function')
🧪 Testing
To run the test suite:
# Install development dependencies
pip install -e .
pip install pytest
# Run tests
pytest test_qck.py -v
Metadata
Release files for qck 2025.8.28
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qck-2025.8.28.tar.gz | 5.4 kB | Without provenance | Details for qck-2025.8.28.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qck-2025.8.28-py3-none-any.whl | Python 3 | none | any | Details for qck-2025.8.28-py3-none-any.whl |
Total release size: 11.1 kB
Release files / qck-2025.8.28.tar.gz
| Download URL | qck-2025.8.28.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a77c76f6511208df5e7deae617084ef2587a4671a876deef84547eca0e19fc53
|
|
BLAKE2b-256 checksum How to use checksums |
eee34d5294504439c49b736828918b30a35672592cd34c07356f63552d1cb5fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / qck-2025.8.28-py3-none-any.whl
| Download URL | qck-2025.8.28-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
031f3c77e8e133fa543b4821595faa2bcda484d86558e19e1b437838db9bfb94
|
|
BLAKE2b-256 checksum How to use checksums |
82cf7a5cc17f333f1f5704698303cc4ad9fea8663af1a97e448e25b39f427f21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for qck 2025.8.28
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.