ggsql
  • Home
  • Installing ggsql
  • Syntax
    • Overview

    • VISUALISE
    • DRAW
    • SCALE
    • FACET
    • PROJECT
    • LABEL
  • Examples
  • Source Code
  • Report a Bug

ggsql is still in early development and all functionality is subject to change

SQL meets Grammar of Graphics

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

Get Started View Examples

Features

Pure SQL Foundation

Write standard SQL queries and seamlessly extend them with visualization clauses. Your existing SQL knowledge transfers directly.

SELECT date, revenue, region
FROM sales
WHERE year = 2024
VISUALISE date AS x, revenue AS y
DRAW line

Grammar of Graphics

Compose visualizations from independent layers, scales, and coordinates. Mix and match geoms, facets, and themes for precise control.

DRAW line 
    MAPPING x AS date, y AS value
DRAW point 
    MAPPING x AS date, y AS value
SCALE x 
    SETTING type => 'date'
FACET WRAP region

Pluggable Architecture

Connect to DuckDB, PostgreSQL, or SQLite. Output to Vega-Lite, ggplot2, or render directly to PNG.

-- Use any data source
ggsql exec "SELECT ..."
  --reader duckdb://data.db
  --writer vegalite
  --output viz.json

Built for Modern Workflows

Jupyter Kernel

Interactive notebooks with inline Vega-Lite visualizations. Persistent database sessions across cells.

Learn more →

VS Code Extension

Syntax highlighting for .ggsql files with full SQL and visualization clause support.

Learn more →

REST API

Build dashboards and web applications with the ggsql-rest server. CORS-enabled with sample data loading.

Learn more →

CLI Tool

Parse, validate, and execute queries from the command line. Perfect for automation and CI pipelines.

Learn more →

Quick Example

-- Create a multi-layer visualization
SELECT date, revenue, region
FROM sales
WHERE year >= 2023

VISUALISE date AS x, revenue AS y, region AS color

DRAW line
DRAW point 
    SETTING size => 3

SCALE x 
    SETTING type => 'date'
SCALE y 
    SETTING type => 'linear', limits => [0, 100000]

FACET WRAP region SETTING scales => 'free_y'

LABEL
  title => 'Revenue Trends by Region',
  x => 'Date',
  y => 'Revenue (USD)'

What’s happening here?

  1. SQL Query retrieves sales data filtered by year
  2. VISUALISE maps columns to visual aesthetics
  3. DRAW creates line and point layers
  4. SCALE configures the x-axis as temporal
  5. FACET creates small multiples by region
  6. LABEL adds descriptive titles

The output is a Vega-Lite specification that renders as an interactive chart.

Ready to get started?

Install ggsql and start creating visualizations in minutes.

Installation Guide Syntax Reference GitHub

  • Report an issue