Export SQL query results to Parquet and CSV... and upload to S3 or MinIO
Project description
sqlxport
Modular CLI + API tool to extract data from PostgreSQL, Redshift, SQLite (and more), exporting to formats like Parquet/CSV, with optional S3 upload and Athena integration.
✅ Features
- 🔄 Run custom SQL queries against PostgreSQL, Redshift, SQLite
- 📦 Export to Parquet or CSV (
--format) - 🩣 Upload results to S3 or MinIO
- 🔄 Redshift
UNLOADsupport (--export-mode redshift-unload) - 🧹 Partition output by column
- 📜 Generate Athena
CREATE TABLEDDL - 🔍 Preview local or remote Parquet/CSV files
- ⚙️
.envsupport for convenient config - 🐍 Reusable Python API
❓ Why SQLxport?
SQLxport simplifies data export workflows and is designed for automation:
- ✅ One command gives you SQL → Parquet/CSV → S3
- 🧱 Works locally, in CI, or inside Docker
- 🪢 Connects to Athena, MinIO, Redshift easily
- 🔌 Clean format and database plugin model
- 🧪 Fully tested, scriptable, production-ready
📦 Installation
pip install .
# or for development
pip install -e .
🚀 Usage
Choose Export Mode
--export-mode |
Compatible DB URLs | Description |
|---|---|---|
postgres-query |
postgresql://, postgres:// |
SELECT + local export |
redshift-unload |
redshift:// |
UNLOAD to S3 |
sqlite-query |
sqlite:///path.db |
For local/lightweight testing |
CLI Examples
Basic Export
sqlxport run \
--export-mode postgres-query \
--db-url postgresql://user:pass@localhost:5432/mydb \
--query "SELECT * FROM users" \
--output-file users.parquet \
--format parquet
S3 Upload
sqlxport run \
--export-mode postgres-query \
--db-url postgresql://... \
--query "..." \
--output-file users.parquet \
--s3-bucket my-bucket \
--s3-key users.parquet \
--s3-access-key AKIA... \
--s3-secret-key ... \
--s3-endpoint https://s3.amazonaws.com
Partitioned Export
sqlxport run \
--export-mode postgres-query \
--db-url postgresql://... \
--query "..." \
--output-dir output/ \
--partition-by group_column \
--format csv
Redshift UNLOAD Mode
sqlxport run \
--export-mode redshift-unload \
--db-url redshift://... \
--query "SELECT * FROM large_table" \
--s3-output-prefix s3://bucket/unload/ \
--iam-role arn:aws:iam::123456789012:role/MyUnloadRole
🐍 Python API
from sqlxport.api.export import run_export, ExportJobConfig
config = ExportJobConfig(
db_url="sqlite:///test.db",
query="SELECT * FROM users",
format="csv",
output_file="out.csv",
export_mode="sqlite-query"
)
run_export(config)
🧪 Running Tests
pytest tests/unit/
pytest tests/integration/
pytest tests/e2e/
🔧 Environment Variables
Supports .env or exported shell variables:
DB_URL=postgresql://username:password@localhost:5432/mydb
S3_BUCKET=my-bucket
S3_KEY=data/users.parquet
S3_ACCESS_KEY=...
S3_SECRET_KEY=...
S3_ENDPOINT=https://s3.amazonaws.com
IAM_ROLE=arn:aws:iam::123456789012:role/MyUnloadRole
Generate a template with:
sqlxport run --generate-env-template
🛠 Roadmap
- ✅ Modular export modes
- ✅ CSV and partitioned output
- ⏳ Add
jsonl,xlsxformats - ⏳ Plugin system for writers/loaders
- ⏳ SaaS mode / UI platform
- ⏳ Kafka/Kinesis streaming support
🔐 Security
- Don’t commit
.envfiles - Use credential vaults when possible
👨💼 Author
Vahid Saber
Built with ❤️ for data engineers and developers.
📄 License
MIT License
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 sqlxport-0.2.0.tar.gz.
File metadata
- Download URL: sqlxport-0.2.0.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc8e645dcd2d4def6e13f5546829718122dcb9ae0caaf92b2c7b79f768f5e97b
|
|
| MD5 |
15f5c2fda125b53f4193e99115093737
|
|
| BLAKE2b-256 |
9185610cee7bb41b4f4399379d36aea5d6e0b59a2a7fd672c8877b4478c00f25
|
File details
Details for the file sqlxport-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sqlxport-0.2.0-py3-none-any.whl
- Upload date:
- Size: 44.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859e3257dc5a6d7a2641fb33e258757d0e6bcb89ccb3d0f919bc982b92db6287
|
|
| MD5 |
d0adfec86afabb60a7dc155abc155cae
|
|
| BLAKE2b-256 |
f95035bddcb2d6ee77d4a5e52fd70e8f6649e7512377224bf5483949690f6b60
|