Fast SQL-only data application builder. Automatically build a UI on top of SQL queries.
SQLpage
[SQLPage](https://sql-page.com) is an **SQL**-only webapp builder.
It allows building powerful data-centric user interfaces quickly,
by tranforming simple database queries into interactive websites.
With SQLPage, you write simple .sql files containing queries to your database
to select, group, update, insert, and delete your data, and you get good-looking clean webpages
displaying your data as text, lists, grids, plots, and forms.
Examples
Code
Result
sql
SELECT'list'as component,
'Popular websites'as title;
SELECT
name as title,
url as link,
CASE type
WHEN1THEN'blue'ELSE'red'ENDas color,
description, icon, active
FROM website;
sql
SELECT'chart'as component,
'Quarterly Revenue'as title,
'area'as type;
SELECT
quarter AS x,
SUM(revenue) AS y
FROM finances
GROUPBY quarter
sql
SELECT'form'as component,
'User'as title,
'Create new user'as validate;
SELECT
name, type, placeholder,
required, description
FROM user_form;
INSERT INTOuserSELECT $first_name, $last_name, $birth_date
WHERE $first_name ISNOT NULL;
sql
select'tab'as component, trueas center;
select'Show all cards'as title, '?'as link,
$tab isnullas active;
select
format('Show %s cards', color) as title,
format('?tab=%s', color) as link,
$tab=color as active
from tab_example_cards
groupby color;
select'card'as component;
select
title, description, color
image_url as top_image, link
from tab_example_cards
where $tab isnullor $tab = color;
select'text'as component,
sqlpage.read_file_as_text('footer.md') as contents_md
Optionally, you can also mount a directory containing sqlpage's configuration file,
custom components, and migrations
(see configuration.md) to /etc/sqlpage in the container.
And place your website in a folder named source and your sqlpage.json in a folder named configuration.
If you want to build your own docker image, taking the raw sqlpage image as a base is not recommended, since it is extremely stripped down and probably won't contain the dependencies you need. Instead, you can take debian as a base and simply copy the sqlpage binary from the official image to your own image:
dockerfile
FROM debian:stable-slim
COPY --from=lovasoa/sqlpage:main /usr/local/bin/sqlpage /usr/local/bin/sqlpage
We provide compiled binaries only for the x86_64 architecture, but provide docker images for other architectures, including arm64 and armv7. If you want to run SQLPage on a Raspberry Pi or
a cheaper ARM cloud instance, using the docker image is the easiest way to do it.
SQLPage supports ODBC connections to connect to databases that don't have native drivers.
You can skip this section if you want to use one of the built-in database drivers (SQLite, PostgreSQL, MySQL, Microsoft SQL Server).
Linux and MacOS release binaries contain a built-in statically linked ODBC driver manager (unixODBC).
You still need to install or provide the database-specific ODBC driver for the database you want to connect to.
It will look like this: Driver=/opt/snowflake_odbc/lib/libSnowflake.so;Server=xyz.snowflakecomputing.com;Database=MY_DB;Schema=PUBLIC;UID=my_user;PWD=my_password
It must reference the path to the database driver you installed earlier, plus any connection parameter required by the driver itself. Follow the instructions from the driver's own documentation.
SQLPage is a web server written in
rust
and distributed as a single executable file.
When it receives a request to a URL ending in .sql, it finds the corresponding
SQL file, runs it on the database,
passing it information from the web request as SQL statement parameters.
When the database starts returning rows for the query,
SQLPage maps each piece of information in the row to a parameter
in one of its pre-defined components' templates, and streams the result back
to the user's browser.
Examples
TODO list: a simple todo list application, illustrating how to create a basic CRUD application with SQLPage.
Plots, Tables, forms, and interactivity: a short well-commented demo showing how to use plots, tables, forms, and interactivity to filter data based on an URL parameter.
Image gallery: An image gallery where users can log in and upload images. Illustrates the implementation of a user authentication system using session cookies, and the handling of file uploads.
User Management: An authentication demo with user registration, log in, log out, and confidential pages. Uses PostgreSQL.
Single sign-on: An example of how to implement OAuth and OpenID Connect (OIDC) authentication in SQLPage. The demo also includes a CAS (Central Authentication Service) client.
Dark theme : demonstrates how to let the user toggle between a light theme and a dark theme, and store the user's preference.
SQLPage can be configured through either a configuration file placed in sqlpage/sqlpage.json
or environment variables such as DATABASE_URL or LISTEN_ON.
Additionally, custom components can be created by placing .handlebars
files in sqlpage/templates. Example.
HTTPS
SQLPage supports HTTP/2 and HTTPS natively and transparently.
Just set SQLPAGE_HTTPS_DOMAIN=example.com, and SQLPage
will automatically request a trusted certificate and
start encrypting all your user's traffic with it.
No tedious manual configuration for you,
and no annoying "Connection is Not Secure" messages for your users !
Serverless
You can run SQLpage serverless
by compiling it to an AWS Lambda function.
An easy way to do so is using the provided docker image: