Skip to main content

Introduction

PythonReports is a toolkit aimed to build database reports in Python® programs. The toolkit includes the report builder and printout renderer for PDF output.

Report builder applies a template to a sequence of uniform data objects and produces a printout structure that can be saved in a file and/or rendered to PDF.

It is possible to render printouts for other presentation formats such as a specific printer language or a GUI toolkit display. There used to be printing output for wxPython and screen display for Tkinter and wxPython, but they fell out of use and their support is discontinued.

Requirements

Current version of PythonReports has only been tested with Python v3.12. Earlier versions of Python3 may or may not work; Python2 is not supported starting from PythonReports v1.0.0.

Report building and printout rendering require the ReportLab Toolkit. Reports containing images additionally require Python Imaging Library: Pillow (preferred) or PIL.

Templates in RSON format (introduced in v0.7.0) require rsonlite.

QR barcodes (introduced in v0.8.0) require qrcode.

Quick Start

A report is built from a list of data dictionaries or data objects having uniform structure. An example of such data is a list of rows fetched from an SQL server.

Report layout is defined by a template file which can have either XML format or a textual format based on rsonlite.

Report builder applies loaded template to a list of data objects and produces a printout structure. Printout can be saved in XML format.

PDF writer creates an output file from a printout structure.

There are example templates in the package sources: sakila.prt is in XML format, and sakila.prtr is the same template in RSON format. The data file for those templates can be found in the project downloads.

This is an example of building a PDF from that data:

import pickle
from PythonReports.api import Builder, parse_rson, write_pdf

with open("sakila.dat", "rb") as data_file:
    data = pickle.load(data_file, encoding="latin1")[:200]
template = parse_rson("sakila.prtr")
build = Builder(template)
printout = build.run(data)
with open("sakila.prp", "wb") as printout_file:
    printout.write(printout_file)
# It is necessary to call .validate() on built or loaded printout
# before creating PDF output.
printout.validate()
write_pdf(printout, "sakila.pdf")

Release files for PythonReports 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PythonReports 1.0.0
File Size Uploaded
PythonReports-1.0.0.tar.gz 147.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PythonReports 1.0.0
File Interpreter ABI Platform
PythonReports-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 268.6 kB

Release files / PythonReports-1.0.0.tar.gz

Download URL PythonReports-1.0.0.tar.gz
Size 147.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9b3e054967cde0ca86d11cecc1c8aa68a8bddd8b467ff9e1a1bf37fc93de5869
BLAKE2b-256 checksum
How to use checksums
773b612e838e476626e0f73d0bceed76c0e2f99aaf298f3e6059320639371815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / PythonReports-1.0.0-py3-none-any.whl

Download URL PythonReports-1.0.0-py3-none-any.whl
Size 120.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e9eef38af6b0ee226e4449a226695a81af3c21f9e9b2900f6d53cebb6ceb6f2
BLAKE2b-256 checksum
How to use checksums
ca1f77cf6cd1fecb0af3a97573ace0989952b82a2cb622009829c1c0a3139df8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.10.1

1 release file

0.10.0

1 release file

0.9.5

1 release file

0.9.4

2 release files

0.9.3

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

0.6.6

0.6.5

0.6.4

0.6.3

0.6.2

0.6.1

0.6.0

0.5.0

0.4.0

0.3.3

0.3.2

0.3.1

0.3.0

0.2.1

0.2.0

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page