What is PageQL?
PageQL is an experimental template language and micro Python web framework that allows embedding SQL inside HTML directly. It was inspired by ColdFusion language that allows embedding SQL and Handlebars / Mustache logic-less templates and also HTMX that simplifies web development.
pip install pageql
pageql data.db templates --create
Core Philosophy
PageQL aims to simplify web development involving relational data by allowing direct embedding of SQL-like queries within HTML templates.
Minimal
The language fully embraces SQL and HTML and adds as few features as needed to implement the common 80 % of web site features—lists, forms, CRUD—while leaving power-user cases to extensions
Declarative Focus
While control structures exist, extensive scripting is discouraged to maintain clarity.
Leverages SQL
PageQL relies on the underlying SQL engine for expression evaluation, rather than implementing its own complex expression language.
Key Tags
#from
- Query and loop over database data#insert / #update / #delete
- SQL data manipulation commands#set
- Set variables#param
- Validate and bind request parameters#import
- Import modules#partial
- Create reusable template blocks#render
- Render imported modules or partials with parameters#if / #else / #ifdef / #ifndef
- Conditional rendering#redirect
- HTTP redirects
Example Code
{{!-- Ensure the table exists (harmless if already created) --}}
{{#create table if not exists todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
text TEXT NOT NULL,
completed INTEGER DEFAULT 0 CHECK(completed IN (0,1))
)}}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Todos (read‑only)</title>
</head>
<body>
<h1>Todos</h1>
<ul>
{{!-- 🚀 Query & loop in one tag --}}
{{#from todos ORDER BY id}}
<li>{{text}}</li>
{{/from}}
</ul>
</body>
</html>
Future plans
PageQL was built with a simple core language but lots of extensibility in mind
Embeddable, simple, performant
While the current implementation is in Python, the language is designed to be simple enough to be reimplemented in any language (C / C++ / Rust / JavaScript...)
Reactivity
The language was designed to have a relational reactive mode. As both HTML and SQL are declarative, it's much easier to reason about then if an imperative language is used as a glue .
Client based, offline mode with SQL database automatic syncing.
Lots of web frameworks get very complex when client and server code is mixed. PageQL solves it by creating a simple SQL change synchronization protocol as an orthogonal project. As long as reactive SQL updates are used, and SQL database is the main data store, the cognitive overhead remains low with this approach.
Mustache / Handlebars / Jinja like templating API
As PageQL combines a micro web framework with a templating engine, templating can be used directly as well from other frameworks, it's just not documented yet.
Advanced routing, importing modules, authentication, authorization, production deployment, optimization
As PageQL is a micro framework / experiment, right now it's for hobbyist projects and feedback.