Crate sqlpage

Source
Expand description

SQLPage is a high-performance web server that converts SQL queries into dynamic web applications by rendering handlebars templates with data coming from SQL queries declared in .sql files.

§Overview

SQLPage is a web server that lets you build data-centric applications using only SQL queries. It automatically converts database queries into professional-looking web pages using pre-built components for common UI patterns like tables, charts, forms, and more.

§Key Features

§Architecture

The crate is organized into several key modules:

  • webserver: Core HTTP server implementation using actix-web
  • render: Component rendering system, streaming rendering of the handlebars templates with data
  • templates: Pre-defined UI component definitions
  • file_cache: Caching layer for SQL file parsing
  • filesystem: Abstract interface for disk and DB-stored files
  • app_config: Configuration and environment handling

§Query Processing Pipeline

When processing a request, SQLPage:

  1. Parses the SQL using sqlparser-rs. Once a SQL file is parsed, it is cached for later reuse.
  2. Executes queries through sqlx.
  3. Finds the requested component’s handlebars template in the database or in the filesystem.
  4. Maps results to the component template, using handlebars-rs.
  5. Streams rendered HTML to the client.

§Extended Functionality

§Example

-- Open a data list component
SELECT 'list' as component, 'Users' as title;

-- Populate it with data
SELECT
    name as title,
    email as description
FROM users
ORDER BY created_at DESC;

For more examples and documentation, visit:

Modules§

Macros§

Structs§

Constants§

  • TEMPLATES_DIR is the directory where .handlebars files are stored When a template is requested, it is looked up in sqlpage/templates/component_name.handlebars in the database, or in $SQLPAGE_CONFIGURATION_DIRECTORY/templates/component_name.handlebars in the filesystem.