Geração de relatórios em Python — CSV, XLSX e PDF com performance de Rust.
Project description
pyreps
Geração de relatórios em Python — CSV, XLSX e PDF com performance de Rust. ⚡
Documentação · PyPI · Issues
✨ Destaques
- 🚀 Alta Performance — Pipeline 100% streaming. CSV e XLSX usam < 1 MB de RAM com 500K+ linhas.
- 🦀 Powered by Rust — XLSX via
rustpy-xlsxwriter, JSON viaorjson. - 📄 3 Formatos — CSV, XLSX e PDF com uma única API.
- 🔌 Plugável — Aceita
list[dict], JSON, SQL ou qualquer fonte custom. - 🎯 Tipos Declarativos — Coerção automática para
int,float,bool,date,datetime. - 🪶 Leve — 3 dependências de runtime. Sem pandas, sem numpy.
Instalação
pip install pyreps
Exemplo Rápido
from pyreps import ColumnSpec, ReportSpec, generate_report
data = [
{"id": 1, "cliente": {"nome": "Ana"}, "total": 100.50},
{"id": 2, "cliente": {"nome": "Bruno"}, "total": 250.00},
]
spec = ReportSpec(
output_format="csv", # ou "xlsx" ou "pdf"
columns=[
ColumnSpec(label="ID", source="id", type="int", required=True),
ColumnSpec(label="Cliente", source="cliente.nome"),
ColumnSpec(label="Total", source="total", type="float",
formatter=lambda v: f"R$ {v:.2f}"),
],
)
path = generate_report(data_source=data, spec=spec, destination="vendas.csv")
Formatos Suportados
| Formato | Renderer | Motor | Streaming |
|---|---|---|---|
| CSV | CsvRenderer |
csv stdlib (C) |
✅ Memória constante |
| XLSX | XlsxRenderer |
rustpy-xlsxwriter (Rust) |
✅ Memória constante |
PdfRenderer |
reportlab (C) |
⚠️ Materializa (layout) |
Fontes de Dados
| Fonte | Adapter | Detecção |
|---|---|---|
list[dict] / generator |
ListDictAdapter |
Automática |
| JSON string / bytes | JsonAdapter |
Automática |
dict / Mapping |
JsonAdapter |
Automática |
| SQL query | SqlAdapter |
Explícito |
| Custom | Implemente InputAdapter |
Explícito |
Tipos Declarativos
ColumnSpec(label="Criado", source="created_at", type="date")
ColumnSpec(label="Ativo", source="active", type="bool") # "sim" → True
ColumnSpec(label="Total", source="total", type="float") # "3.14" → 3.14
Tipos: str, int, float, bool, date, datetime. Opcional — type=None mantém pass-through.
XLSX — Largura de Colunas
spec = ReportSpec(
output_format="xlsx",
columns=[...],
metadata={
"xlsx": {
"width_mode": "auto", # "manual" | "auto" | "mixed"
"sheet_name": "Vendas",
"columns": {
"ID": {"width": 8.0},
"Descrição": {"min_width": 20.0, "max_width": 50.0},
},
}
},
)
SQL
from pyreps import SqlAdapter
generate_report(
data_source=None,
spec=spec,
destination="vendas.csv",
input_adapter=SqlAdapter(
query="SELECT id, name, total FROM sales",
connection=connection,
),
)
Performance
Benchmark com 6 colunas e tipos declarativos:
| Formato | 500K linhas | Peak RAM | rows/s |
|---|---|---|---|
| CSV | 15s | 0.16 MB | ~33K |
| XLSX | 24s | 0.62 MB | ~21K |
CSV e XLSX mantêm memória constante independente do volume.
Documentação
📖 Documentação completa em pyreps.readthedocs.io
Licença
MIT
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 pyreps-0.1.5.tar.gz.
File metadata
- Download URL: pyreps-0.1.5.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8beb13bbaf27542c518c4cdee7f4c9b361fcf54915959839fe1c30ff6721dfdc
|
|
| MD5 |
7be1967bb62e67e62e0a80150a2bcf72
|
|
| BLAKE2b-256 |
97b9060284e1c90ea948409c2f2e094adb1cf51a3dae575631e27a45215cb81f
|
Provenance
The following attestation bundles were made for pyreps-0.1.5.tar.gz:
Publisher:
publish.yml on JhonatanRian/pyreps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyreps-0.1.5.tar.gz -
Subject digest:
8beb13bbaf27542c518c4cdee7f4c9b361fcf54915959839fe1c30ff6721dfdc - Sigstore transparency entry: 1376401192
- Sigstore integration time:
-
Permalink:
JhonatanRian/pyreps@584bb63c2a8226d3231511f643e1814c76eb7cac -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/JhonatanRian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@584bb63c2a8226d3231511f643e1814c76eb7cac -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyreps-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pyreps-0.1.5-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ce880170528f8149ff7a26ac43c884172ceb889aca8bb4f862f158ca3c249c5
|
|
| MD5 |
504dfe50009375a0b2ae7c167b2b633c
|
|
| BLAKE2b-256 |
0816085424649a6de7fca4de3b94cbd31a97b36a5ae9336a770e23769bab9135
|
Provenance
The following attestation bundles were made for pyreps-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on JhonatanRian/pyreps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyreps-0.1.5-py3-none-any.whl -
Subject digest:
0ce880170528f8149ff7a26ac43c884172ceb889aca8bb4f862f158ca3c249c5 - Sigstore transparency entry: 1376401197
- Sigstore integration time:
-
Permalink:
JhonatanRian/pyreps@584bb63c2a8226d3231511f643e1814c76eb7cac -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/JhonatanRian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@584bb63c2a8226d3231511f643e1814c76eb7cac -
Trigger Event:
push
-
Statement type: