Skip to main content

A Python library for SQL query visualization with interactive charts using Plotly

Project description

SQLViz

SQLViz is a Python library that allows you to query SQL databases and visualize the results directly using Plotly charts.


Installation

pip install sqlviz

Features

  • Query any SQL database supported by SQLAlchemy.
  • Generate charts (bar, line, scatter, etc.) from SQL queries.
  • CLI utility to quickly visualize SQL results.
  • Auto-detect x/y columns when not provided.

CLI Usage

You can use SQLViz from the command line to generate charts directly from your database.

Syntax

sqlviz-cli --db-uri <DATABASE_URI> --sql "<SQL_QUERY>" --chart-type <CHART_TYPE> [--x <X_COLUMN>] [--y <Y_COLUMN>] [--show False]

Parameters

  • --db-uri: SQLAlchemy database URI (e.g., sqlite:///mydata.db).
  • --sql: SQL query to fetch data.
  • --chart-type: Type of chart (bar, line, scatter, etc.).
  • --x: (Optional) Column name for X-axis.
  • --y: (Optional) Column name for Y-axis.
  • --show: Whether to display the chart immediately (default: True).

Example

sqlviz-cli --db-uri sqlite:///test.db --sql "SELECT * FROM t" --chart-type bar --x x --y y --show False

This will generate a bar chart from the t table in test.db, mapping x to X-axis and y to Y-axis, without displaying it immediately.


Python Usage

from sqlviz.core import visualize_sql_cli

fig = visualize_sql_cli(
    db_uri="sqlite:///test.db",
    sql="SELECT * FROM t",
    chart_type="bar",
    show=True,
    kwargs_str='{"x": "x", "y": "y"}'
)

fig is a Plotly Figure object and can be further customized or saved.


License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlviz-0.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlviz-0.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file sqlviz-0.0.1.tar.gz.

File metadata

  • Download URL: sqlviz-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sqlviz-0.0.1.tar.gz
Algorithm Hash digest
SHA256 753d025ce15e0f4a5aa6ef59f53b4350aab0fffca25c38d7dacbc7975921a59c
MD5 4ec71d037a6399052a197167fed27ca2
BLAKE2b-256 b030eafd847e511c321d9cc1925361b46a741c4c84e265c8f60ac2452d979e29

See more details on using hashes here.

File details

Details for the file sqlviz-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sqlviz-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sqlviz-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f5681df3c24a06d62adaa6ef18c92a1cb1677ac74bc5a3dc6decc93891642c0
MD5 42499c9f279af4e205c53a73d1ed8a84
BLAKE2b-256 6d496d07e7329ba93ad35bf85baef56a5835a1c445e5a19d49f6e044e8467651

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page