query-viz
Render tabular query results as chart images. Rows in, PNG out.
query-viz does one thing: it turns a list of row dicts (exactly what a data
warehouse driver such as BigQuery, Snowflake or Postgres hands back) into a chart
image. No agent framework, no cloud SDK, no DataFrame requirement. That makes it
a clean building block for an LLM agent tool, a report generator, or any
pipeline that has already fetched data and wants a picture of it.
from query_viz import render_chart
png = render_chart(
rows=[
{"month": "Jan", "signups": 120},
{"month": "Feb", "signups": 155},
{"month": "Mar", "signups": 143},
],
chart_type="bar", # bar | line | pie | scatter
x="month",
y="signups",
title="Signups by month",
)
with open("signups.png", "wb") as fh:
fh.write(png)
Why a library
It was extracted from an ADK marketing agent's "chart this query" tool. The
rendering is pure and reusable; the agent-specific parts (running a guarded
query, uploading the image to Drive) stay in the agent as a thin wrapper. Same
split as sql-guard: the reusable
engine is a library, the framework glue is not.
API
render_chart(
rows, # Sequence[Mapping[str, Any]]
*,
chart_type, # "bar" | "line" | "pie" | "scatter"
x, # category / x-axis column (pie slice labels)
y=None, # numeric value column (required for every type)
title="",
dpi=120,
figsize=(10.0, 6.0),
palette=None, # brand colours, applied in order
color_map=None, # permanent category-to-colour pins
color_overrides=None, # one-off pins for this chart; beat color_map
) -> bytes # PNG image bytes
bar,line,scatterneed bothxandy.pieusesxfor slice labels andyfor slice sizes.- Non-numeric
yvalues coerce to0.0rather than erroring, so a strayNonewon't sink a whole chart. - Raises
ChartError(aValueError) for an unsupported type, empty rows, or a missing column. - Colour pins are keyed by the category value for
barandpie, and by theycolumn name forlineandscatter, which draw a single series.
Design notes
- Headless. Forces matplotlib's
Aggbackend, so it renders on a server with no display. - Pure. No I/O, no globals: deterministic given its inputs, and safe to
call from a worker thread (
asyncio.to_thread). - Typed. Ships
py.typed.
Install
pip install query-viz
The distribution is named query-viz; the import package is query_viz. Only
dependency is matplotlib.
License
Apache-2.0. See LICENSE.
Metadata
Release files for query-viz 0.1.0
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 |
|---|---|---|---|---|
| query_viz-0.1.0.tar.gz | 15.7 kB | With provenance | Details for query_viz-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| query_viz-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for query_viz-0.1.0-py3-none-any.whl |
Total release size: 29.4 kB
Release files / query_viz-0.1.0.tar.gz
| Download URL | query_viz-0.1.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c5f9ee5e1a0e7f2e6be80e7c9231ef4dd6005a8086b745e46fc6702f21842f1
|
|
BLAKE2b-256 checksum How to use checksums |
27e9d6117b6487ead03b8e54b98b5b2187f3048ebeb529805c997937a5106b33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / query_viz-0.1.0-py3-none-any.whl
| Download URL | query_viz-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19ef03112f7f465404a1696c5c46f1f882b1ca482c42f6f255de6c417e1342d2
|
|
BLAKE2b-256 checksum How to use checksums |
2dc60764a4f583e98c55e5887caf19705bca13ea8ac0f66292a21f5e3072bbb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for query-viz 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for query_viz-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA 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.