SQLPage v0.20.3 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 "text" component

A paragraph of text. The entire component will render as a single paragraph, with each item being rendered as a span of text inside it, the styling of which can be customized using parameters.

Top-level parameters

center

Whether to center the title.

contents

A top-level paragraph of text to display, without any formatting, without having to make additional queries.

contents_md

Rich text in the markdown format. Among others, this allows you to write bold text using **bold**, italics using *italics*, and links using [text](https://example.com).

html

Raw html code to include on the page. Don't use that if you are not sure what you are doing, it may have security implications.

id

id attribute added to the container in HTML. It can be used to target this item through css or for scrolling to this item through links (use "#id" in link url).

title

Text header before the paragraph.

width

How wide the paragraph should be, in characters.

Row-level parameters

contents

REQUIRED. A span of text to display

bold

Whether the span of text should be displayed as bold.

break

Indicates that the current span of text starts a new paragraph.

code

Use a monospace font. Useful to display the text as code.

color

The name of a color for this span of text.

italics

Whether the span of text should be displayed as italics.

link

An URL to which the user should be taken when they click on this span of text.

size

A number between 1 and 6 indicating the font size.

underline

Whether the span of text should be underlined.

Example 1

Rendering a simple text paragraph.

select 
    'text'              as component,
    'Hello, world ! <3' as contents;

Result

Hello, world ! <3

Example 2

Rendering rich text using markdown

select 
    'text' as component,
    '
# Markdown in SQLPage

## Simple formatting

SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, [external links](https://github.com/lovasoa/sqlpage), [links to other pages](/index.sql) and [intra-page links](#my-paragraph). 

## Lists
### Unordered lists
* SQLPage is easy
* SQLPage is fun
* SQLPage is free

### Ordered lists
1. SQLPage is fast
2. SQLPage is safe
3. SQLPage is open-source

## Code
```sql
SELECT ''list'' AS component;
SELECT name as title FROM users;
```

## Tables

| SQLPage component | Description  | Documentation link  |
| --- | --- | --- |
| text | A paragraph of text. | [Documentation](https://sql.ophir.dev/documentation.sql?component=text) |
| list | A list of items. | [Documentation](https://sql.ophir.dev/documentation.sql?component=list) |
| steps | A progress indicator. | [Documentation](https://sql.ophir.dev/documentation.sql?component=steps) |
| form | A series of input fields. | [Documentation](https://sql.ophir.dev/documentation.sql?component=form) |

## Quotes
> Fantastic.
>
> — [HackerNews User](https://news.ycombinator.com/item?id=36194473#36209061) about SQLPage

## Images
![SQLPage logo](https://sql.ophir.dev/favicon.ico)

## Horizontal rules
---

' as contents_md;

Result

Markdown in SQLPage

Simple formatting

SQLPage supports only plain text as column values, but markdown allows easily adding bold, italics, external links, links to other pages and intra-page links.

Lists

Unordered lists

  • SQLPage is easy
  • SQLPage is fun
  • SQLPage is free

Ordered lists

  1. SQLPage is fast
  2. SQLPage is safe
  3. SQLPage is open-source

Code

SELECT 'list' AS component;
SELECT name as title FROM users;

Tables

SQLPage component Description Documentation link
text A paragraph of text. Documentation
list A list of items. Documentation
steps A progress indicator. Documentation
form A series of input fields. Documentation

Quotes

Fantastic.

HackerNews User about SQLPage

Images

SQLPage logo

Horizontal rules


Example 3

Rendering a paragraph with links and styling.

select 
    'text'      as component,
    'About SQL' as title;
select 
    'SQL' as contents,
    TRUE  as bold,
    TRUE  as italics;
select 
    ' is a domain-specific language used in programming and designed for managing data held in a ' as contents;
select 
    'relational database management system' as contents,
    'https://en.wikipedia.org/wiki/Relational_database' as link;
select 
    '. It is particularly useful in handling structured data.' as contents;

Result

About SQL

SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system. It is particularly useful in handling structured data.

Example 4

An intra-page link to a section of the page.

select 
    'text' as component,
    'This is a link to the [next paragraph](#my-paragraph). You can open this link in a new tab and the page will scroll to the paragraph on load.' as contents_md;
select 
    'text'         as component,
    'my-paragraph' as id,
    'This **is** the next paragraph.' as contents_md;

Result

This is a link to the next paragraph. You can open this link in a new tab and the page will scroll to the paragraph on load.

This is the next paragraph.

Official SQLPage documentation