SQLPage v0.20.1 documentation

If you are completely new to SQLPage, you should start by reading the get started tutorial, which will guide you through the process of creating your first SQLPage application.

Building an application with SQLPage is quite simple. To create a new web page, just create a new SQL file. For each SELECT statement that you write, the data it returns will be analyzed and rendered to the user. The two most important concepts in SQLPage are components and parameters.

To select a component and set its top-level properties, you write the following SQL statement:

SELECT 'component_name' AS component, 'my value' AS top_level_parameter_1;

Then, you can set its row-level parameters by writing a second SELECT statement:

SELECT my_column_1 AS row_level_parameter_1, my_column_2 AS row_level_parameter_2 FROM my_table;

This page documents all the components provided by default in SQLPage and their parameters. Use this as a reference when building your SQL application. If at any point you need help, you can ask for it on the SQLPage forum.

If you know some HTML, you can also easily create your own components for your application.

components

The "card" component

A grid where each element is a small card that displays a piece of data.

Top-level parameters

columns

The number of columns in the grid of cards. This is just a hint, the grid will adjust dynamically to the user's screen size, rendering fewer columns if needed to fit the contents.

description

A short paragraph displayed below the title.

description_md

A short paragraph displayed below the title - formatted using markdown.

title

Text header at the top of the list of cards.

Row-level parameters

title

REQUIRED. Name of the card, displayed at the top.

active

Whether this item in the grid is considered "active". Active items are displayed more prominently.

class

class attribute added to the container in HTML. It can be used to apply custom styling to this item through css. Added in v0.18.0.

color

The name of a color, to be displayed on the left of the card to highlight it.

description

The body of the card, where you put the main text contents of the card. This does not support rich text formatting, only plain text. If you want to use rich text formatting, use the `description_md` property instead.

description_md

The body of the card, in Markdown format. This is useful if you want to display a lot of text in the card, with many options for formatting, such as line breaks, **bold**, *italics*, lists, #titles, [links](target.sql), ![images](photo.jpg), etc.

embed

A url whose contents will be fetched and injected into the body of this card. This can be used to inject arbitrary html content, but is especially useful for injecting the output of other sql files rendered by SQLPage. For the latter case you can pass the ?_sqlpage_embed query parameter, which will skip the shell layout

embed_mode

Set to 'iframe' to embed the target (specified through embed property) in an iframe. Unless this is explicitly set, the embed target is fetched and injected within the parent page. If embed_mode is set to iframe, You can also set height and width parameters to configure the appearance and the sandbox and allow parameters to configure security aspects of the iframe. Refer to the MDN page for an explanation of these parameters.

footer

Muted text to display at the bottom of the card.

footer_link

An URL to which the user should be taken when they click on the footer.

footer_md

Muted text to display at the bottom of the card, with rich text formatting in Markdown format.

icon

Name of an icon to display on the left side of the card.

link

An URL to which the user should be taken when they click on the card.

top_image

The URL (absolute or relative) of an image to display at the top of the card.

Example 1

The most basic card

select 
    'card' as component;
select 
    'A' as description;
select 
    'B' as description;
select 
    'C' as description;

Result

A
B
C

Example 2

A card with a Markdown description

select 
    'card' as component,
    2      as columns;
select 
    'A card with a Markdown description' as title,
    'This is a card with a **Markdown** description. 

This is useful if you want to display a lot of text in the card, with many options for formatting, such as 
 - **bold**, 
 - *italics*, 
 - [links](index.sql), 
 - etc.' as description_md;

Result

A card with a Markdown description

This is a card with a Markdown description.

This is useful if you want to display a lot of text in the card, with many options for formatting, such as

  • bold,
  • italics,
  • links,
  • etc.

Example 3

A beautiful card grid with bells and whistles, showing examples of SQLPage features.

select 
    'card'                     as component,
    'Popular SQLPage features' as title,
    2                          as columns;
select 
    'Download as spreadsheet'  as title,
    '?component=csv#component' as link,
    'Using the CSV component, you can download your data as a spreadsheet.' as description,
    'file-plus'                as icon,
    'green'                    as color,
    'SQLPage can both [read](?component=form#component) and [write](?component=csv#component) **CSV** files.' as footer_md;
select 
    'Custom components'      as title,
    '/custom_components.sql' as link,
    'If you know some HTML, you can create your own components for your application.' as description,
    'code'                   as icon,
    'orange'                 as color,
    'You can look at the [source of the official components](https://github.com/lovasoa/SQLpage/tree/main/sqlpage/templates) for inspiration.' as footer_md;

Result

Popular SQLPage features

Example 4

A gallery of images.

select 
    'card' as component,
    'My favorite animals in pictures' as title,
    3      as columns;
select 
    'Lynx' as title,
    'The **lynx** is a medium-sized **wild cat** native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.' as description_md,
    'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Lynx_lynx-4.JPG/640px-Lynx_lynx-4.JPG' as top_image,
    'star' as icon;
select 
    'Squirrel' as title,
    'The **chipmunk** is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.' as description_md,
    'https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Tamias-rufus-001.jpg/640px-Tamias-rufus-001.jpg' as top_image;
select 
    'Spider' as title,
    'The **jumping spider family** (_Salticidae_) contains more than 600 described genera and about *6000 described species*, making it the largest family of spiders with about 13% of all species.' as description_md,
    'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Jumping_spiders_%28Salticidae%29.jpg/640px-Jumping_spiders_%28Salticidae%29.jpg' as top_image;

Result

My favorite animals in pictures

Lynx

The lynx is a medium-sized wild cat native to Northern, Central and Eastern Europe to Central Asia and Siberia, the Tibetan Plateau and the Himalayas.

Squirrel

The chipmunk is a small, striped rodent of the family Sciuridae. Chipmunks are found in North America, with the exception of the Siberian chipmunk which is found primarily in Asia.

Spider

The jumping spider family (Salticidae) contains more than 600 described genera and about 6000 described species, making it the largest family of spiders with about 13% of all species.

Example 5

Cards with remote content

select 
    'card' as component,
    'Card with embedded remote content' as title,
    2      as columns;
select 
    'Embedded Chart' as title,
    '/examples/chart.sql?_sqlpage_embed' as embed,
    'You can find the sql file that generates the chart [here](https://github.com/lovasoa/SQLpage/tree/main/examples/official-site/examples/chart.sql)' as footer_md;
select 
    'Embedded Video' as title,
    'https://www.youtube.com/embed/mXdgmSdaXkg' as embed,
    'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' as allow,
    'iframe'         as embed_mode,
    '350'            as height;

Result

Card with embedded remote content

Embedded Chart

Loading...

Embedded Video

Official SQLPage documentation