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
- SQL-Only Development: Build full web applications without HTML, CSS, or JavaScript
- Built-in Components: Rich library of pre-made UI components
- Security: Protection against SQL injection, XSS and other vulnerabilities
- Performance: Optimized request handling and rendering
- Database Support: Works with
SQLite
,PostgreSQL
,MySQL
, and MS SQL Server
§Architecture
The crate is organized into several key modules:
webserver
: Core HTTP server implementation using actix-webrender
: Component rendering system, streaming rendering of the handlebars templates with datatemplates
: Pre-defined UI component definitionsfile_cache
: Caching layer for SQL file parsingfilesystem
: Abstract interface for disk and DB-stored filesapp_config
: Configuration and environment handling
§Query Processing Pipeline
When processing a request, SQLPage
:
- Parses the SQL using sqlparser-rs. Once a SQL file is parsed, it is cached for later reuse.
- Executes queries through sqlx.
- Finds the requested component’s handlebars template in the database or in the filesystem.
- Maps results to the component template, using handlebars-rs.
- 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§
- Handles the rendering of SQL query results into HTTP responses using components.
- Core HTTP server implementation handling SQL file execution and request processing.
Macros§
- Defines all sqlpage functions
Structs§
Constants§
TEMPLATES_DIR
is the directory where .handlebars files are stored When a template is requested, it is looked up insqlpage/templates/component_name.handlebars
in the database, or in$SQLPAGE_CONFIGURATION_DIRECTORY/templates/component_name.handlebars
in the filesystem.