Search

Lib.rs

› Database interfaces
#sql #graphics #visualization #specification #break #grammar #declarative-language #query-language #date #sales

ggsql

A declarative visualization language that extends SQL with powerful data visualization capabilities

by George Stagg, Thomas Lin Pedersen, claude, Carson Sievert, ggsql Team

  • Install
  • GitHub repo (posit-dev)
  • Home (ggsql.org)

13 releases

new 0.3.2 May 5, 2026
0.3.1 Apr 30, 2026
0.2.7 Apr 20, 2026
0.1.9 Mar 28, 2026

#821 in Database interfaces

Download history 54/week @ 2026-04-11 150/week @ 2026-04-18 382/week @ 2026-04-25

586 downloads per month
Used in 2 crates

MIT license

4.5MB
99K SLoC

Rust 52K SLoC // 0.1% comments C 45K SLoC // 0.0% comments JavaScript 1K SLoC // 0.0% comments Scheme 89 SLoC // 0.2% comments Python 37 SLoC // 0.2% comments C++ 19 SLoC

ggsql website ggsql

A SQL extension for declarative data visualization based on the Grammar of Graphics.

ggsql allows you to write queries that combine SQL data retrieval with visualization specifications in a single, composable syntax.

Example

SELECT date, revenue, region
FROM sales
WHERE year = 2024

VISUALISE date AS x, revenue AS y, region AS color
DRAW line
SCALE x
  SETTING breaks => 'month'
LABEL title => 'Sales by Region'

Why?

Many data analysts are naturally at home in SQL and spend more time there than in a programming language like Python or R. Having to extract data, context switch to a new programming language, import data, etc. is cumbersome when all you want to do is understand the data you are working with right now.

ggsql is built for immediate familiarity and alignment with the SQL language. It is further built on the foundation of the grammar of graphics known from ggplot2 which affords a composable syntax capable of simple as well as arbitrarily complex visualizations.

The syntax has been designed to be easy to learn, read, and write. This also means that it is a great fit for AI agents to produce as the output query is immediately easy to understand and validate by the user so that you can have certainty in its validity.

Project status

We are approaching an alpha release with the main architectural parts finished. Future development will focus on adding new readers (database support) and writers (output types) to compliment the DuckDB/SQLite + Vegalite setup we have focused on during early development.

Installation

Please follow the instructions on the website for up to date information on how to install ggsql.

Try it out

ggsql compiles to WASM and can thus be embedded in a website. You can try it out on our playground (no installation required).

Learn more

Browse the documentation to learn of all ggsql has to offer. Complete with interactive examples to try out.


lib.rs:

ggsql - SQL Visualization Grammar

A SQL extension for declarative data visualization based on the Grammar of Graphics.

ggsql allows you to write queries that combine SQL data retrieval with visualization specifications in a single, composable syntax.

Example

SELECT date, revenue, region
FROM sales
WHERE year = 2024
VISUALISE date AS x, revenue AS y, region AS color
DRAW line
LABEL title => 'Sales by Region'

Architecture

ggsql splits queries at the VISUALISE boundary:

  • SQL portion → passed to pluggable readers (DuckDB, PostgreSQL, CSV, etc.)
  • VISUALISE portion → parsed and compiled into visualization specifications
  • Output → rendered via pluggable writers (ggplot2, PNG, Vega-Lite, etc.)

Core Components

  • parser - Query parsing and AST generation
  • engine - Core execution engine
  • readers - Data source abstraction layer
  • writers - Output format abstraction layer

Dependencies

~36–48MB
~756K SLoC

  • arrow 56.0
  • bytes
  • chrono
  • const_format
  • csscolorparser 0.8.1
  • default duckdb 1.4.0+bundled+vtab-arrow
  • odbc libloading
  • odbc toml_edit 0.22
  • palette+std+approx
  • default parquet 56.0+arrow+snap
  • rand 0.8
  • regex
  • sqlite rusqlite 0.38+bundled+chrono
  • serde+derive
  • serde_json
  • sprintf 0.4
  • thiserror 1.0
  • tree-sitter 0.26
  • tree-sitter-ggsql
  • uuid+v4
  • build build.rs
  • dev jsonschema 0.44+resolve-file
  • dev tempfile
  • dev ureq 3.0

Other features

  • all-readers
  • builtin-data
  • vegalite
Related: ggsql-cli, ggsql-jupyter, tree-sitter-ggsql
See also: prqlc-parser, apollo-io-cli, vesper-lang, typeql, plotnik-compiler, graphannis, odbc-api, datafusion-table-providers, sqlx-core-oldapi, charton, colorgrad

Lib.rs is an unofficial list of Rust/Cargo crates, created by kornelski. It contains data from multiple sources, including heuristics, and manually curated data. Content of this page is not necessarily endorsed by the authors of the crate. This site is not affiliated with nor endorsed by the Rust Project. If something is missing or incorrect, please file a bug.