csvql-query
Query CSV files with SQL from Python — powered by a Zig/SIMD engine.
Zero-copy mmap reads + SIMD parsing happen before Python ever sees the data. Faster than DuckDB on typical workloads, no dependencies required.
Installation
pip install csvql-query
Quick Start
import csvql
# Returns a list of dicts (like csv.DictReader, but with SQL)
rows = csvql.query("SELECT name, salary FROM 'employees.csv' WHERE salary > 100000 ORDER BY salary DESC")
# [{'name': 'Alice', 'salary': '185000'}, ...]
# Raw CSV string
csv_str = csvql.query_csv("SELECT * FROM 'data.csv' LIMIT 10")
# pandas DataFrame (pandas must be installed)
df = csvql.query_df("SELECT category, COUNT(*) as n FROM 'sales.csv' GROUP BY category")
# (headers, rows) tuples — no dependencies
headers, rows = csvql.query_tuples("SELECT name, age FROM 'users.csv' WHERE age > 25")
API
| Function | Returns | Description |
|---|---|---|
query(sql) |
list[dict] |
Execute SQL, get list of dicts |
query_csv(sql) |
str |
Execute SQL, get raw CSV string |
query_df(sql) |
DataFrame |
Execute SQL, get pandas DataFrame |
query_tuples(sql) |
(list[str], list[tuple]) |
Execute SQL, get (headers, rows) |
SQL Support
The SQL path is embedded in the query string (same as the CLI):
# Filtering, ordering, limiting
csvql.query("SELECT name, city FROM 'data.csv' WHERE age > 30 ORDER BY name LIMIT 5")
# Aggregation
csvql.query("SELECT department, AVG(salary) FROM 'emp.csv' GROUP BY department")
# Unix pipes — use '-' as the filename
import subprocess, sys
# or just pass stdin data via the engine directly
Full SQL reference: SIMPLE_QUERY_LANGUAGE.md
Performance
- mmap + SIMD parsing — data is never copied into Python memory
- Parallel chunk processing on multi-core machines
- Typically 5–9x faster than DuckDB on 1M-row CSVs
Requirements
- Python ≥ 3.10
- macOS (x86_64 / arm64) or Linux (x86_64)
pandasoptional — only needed forquery_df()
Links
Metadata
Release files for csvql-query 1.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| csvql_query-1.9.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| csvql_query-1.9.0-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details |
| csvql_query-1.9.0-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details |
Total release size: 2.5 MB
Release files / csvql_query-1.9.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | csvql_query-1.9.0-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
1acd12a2de7a1985b983bb6c07707ab29379178868c64fe0368a96f9f11b792b
|
|
BLAKE2b-256 checksum How to use checksums |
5b8c080dfde733e39e1e505da6b6c25a273d4ba24260c63d2b2203ff3c1fbfba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / csvql_query-1.9.0-py3-none-macosx_12_0_x86_64.whl
| Download URL | csvql_query-1.9.0-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 385.9 kB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
8d6445e8ad3ad0848d0ae6404029e0e25f17298ca84b08dc293124a1540b6973
|
|
BLAKE2b-256 checksum How to use checksums |
11ffb575b53add5d4ad89713b25cb49e0e1b066c002f9e8ff94b6e5c3b067a0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / csvql_query-1.9.0-py3-none-macosx_12_0_arm64.whl
| Download URL | csvql_query-1.9.0-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 385.9 kB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c7b82e38fb3a7dce5b18c9eed26b35d43ba229676dc0feadd915fa73231a0f7d
|
|
BLAKE2b-256 checksum How to use checksums |
cd41833b9f3fc3a83eb3b0c1fc3ba3c7cba9b89761ad3d0bc9d142d500fdfdb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|