SQLPage built-in functions

In addition to normal SQL functions supported by your database, SQLPage provides a few special functions to help you extract data from user requests.

These functions are special, because they are not executed inside your database, but by SQLPage itself before sending the query to your database. Thus, they require all the parameters to be known at the time the query is sent to your database. Function parameters cannot reference columns from the rest of your query.

The sqlpage.run_sql function

Introduced in SQLPage 0.20.0.

Executes another SQL file and returns its result as a JSON array.


Include a common header in all your pages

It is common to want to run the same SQL queries at the beginning of all your pages, to check if an user is logged in, render a header, etc. You can create a file called common_header.sql, and use the dynamic component with the run_sql function to include it in all your pages.

select 'dynamic' as component, sqlpage.run_sql('common_header.sql') as properties;




Path to the SQL file to execute, can be absolute, or relative to the web root (the root folder of your website sql files). In-database files, from the sqlpage_files(path, contents, last_modified) table are supported.

Official SQLPage documentation