Build Web Apps Using Only SQL: A Guide to SQLPage

5月21日 Published inDeveloper Tools

SQLPage is a SQL-first web application builder that allows you to create data-driven pages using only SQL. No knowledge of traditional web development languages is required.

The platform is compatible with SQLite, PostgreSQL, MySQL, Microsoft SQL Server, and compatible databases such as YugabyteDB or MariaDB. You can use simple SQL queries to display data through text, lists, tables, and charts, or to process user input via forms.

Core Features

Components To define how your data is displayed, set the component field in your SQL query. Available options include list, chart, form, tab, card, and several others.

Example:

SELECT 'list' AS component, 'Popular websites' AS title;
SELECT name AS title, url AS link FROM website;

Dynamic Interactions You can capture user input through URL parameters such as $tab or $todo_id. This enables you to filter data or process form submissions on the fly.

SELECT * FROM todos WHERE id = $todo_id;
INSERT INTO user (first_name, last_name, birth_date)
SELECT $first_name, $last_name, $birth_date
WHERE $first_name IS NOT NULL;

Deployment & Configuration

Deployment Options

  • Binary – Download the release for your operating system, extract it, and run the file. tar -xzf sqlpage-*.tgz && ./sqlpage.bin

  • Docker – Use the official image and mount your local SQL files to the container. docker run -it --name sqlpage -p 8080:8080 --volume "$(pwd):/var/www" --rm lovasoa/sqlpage

  • Homebrew (macOS) brew install sqlpage

  • Serverless – SQLPage can be compiled for AWS Lambda. You can use Docker to build the project and generate a deployable ZIP archive.

Configuration Settings can be managed via a sqlpage.json file or environment variables such as DATABASE_URL and LISTEN_ON. You can enable HTTPS with automatic certificate management by configuring the SQLPAGE_HTTPS_DOMAIN variable.

Tech Stack

  • Backend: Built with Rust and Actix Web for a high-performance, reliable HTTP server.
  • Frontend: Utilizes Tabler CSS for a clean, professional user interface. UI elements are rendered using Handlebars templates. If you need custom layouts, you can provide your own HTML and CSS via .handlebars files or the dedicated html component.

Use Cases & Examples

Data Dashboards

To create an area chart showing quarterly revenue:

SELECT 'chart' AS component, 'Quarterly Revenue' AS title, 'area' AS type;
SELECT quarter AS x, SUM(revenue) AS y FROM finances GROUP BY quarter;

Card Layout with Tabs

SELECT 'tab' AS component, true AS center;
SELECT format('Show %s cards', color) AS title, format('?tab=%s', color) AS link FROM tab_example_cards GROUP BY color;
SELECT title, description, color FROM tab_example_cards WHERE $tab IS NULL OR $tab = color;

Forms – Define a user registration form and handle the data insertion:

SELECT 'form' AS component, 'User' AS title, 'Create new user' AS validate;
SELECT name, type, placeholder, required, description FROM user_form;
INSERT INTO user (first_name, last_name, birth_date)
SELECT $first_name, $last_name, $birth_date
WHERE $first_name IS NOT NULL;

File Uploads & Authentication – Visit the official GitHub repository for detailed examples regarding image galleries and user management systems.

Core Advantages

  • Low Barrier to Entry – SQL is the only required skill. Data scientists and analysts can build functional prototypes without mastering complex frontend frameworks.
  • Development Speed – Focus entirely on your data model. SQLPage handles routing, state management, and UI rendering automatically.
  • Lightweight – Distributed as a single binary with a small Docker footprint. It runs efficiently on ARM devices like the Raspberry Pi.

When to Use SQLPage

  • Internal business tools (CRMs, ticketing systems)
  • Analytics and monitoring dashboards
  • Simple CRUD (Create, Read, Update, Delete) applications
  • Rapid prototyping and MVPs

Quick Start

  1. Download the latest binary from the GitHub releases page or pull the official Docker image.
  2. Create an index.sql file containing a basic query (e.g., a list or a chart).
  3. Start the server and navigate to http://localhost:8080 in your browser.
  4. For advanced configurations, consult the documentation or use Handlebars templates to customize the UI.

SQLPage removes the traditional obstacles to web development. If you understand SQL, you have the tools to build and deploy web applications. It is a practical solution for validating new ideas or shipping internal tools quickly.