|You Can Now Code Websites With SQL|
|Written by Nikos Vaggalis|
|Monday, 21 August 2023|
SQLPage is a fun and innovative open source project that lets you do the presentation layer in plain SQL.
With SQLPage your SQL skills reach beyond manipulating the Data layer of your application; you can now do HTML too without needing to know any of the traditional web programming languages and concepts. The difference is that your SQL includes and refers to UI components as columns.
A simple example will make the goal clear. The following SQL code uses the 'list' component
which gets rendered as :
SELECT 'form' as component, 'User' as title, 'Create new user' as validate;
INSERT INTO user (first_name, last_name, birth_date)
There's a range of ready made UI components. The main ones are:
and more. .
I hear you say, what about aligning those components on the page? How do you do that?
Each component is full width, and they are stacked up from top to bottom. Inside of a single component, there can be multiple columns, and then the layout depends on the particular component. For instance the cards component has a "columns" attribute which is 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.
That said you can also write your own custom components, and then you are free to do whatever you want in CSS. SQLPage uses the great "tabler" CSS library which has a ton of useful utilities.
SQLPage draws on an interesting idea, however I thought that mixing the data and the presentation layers goes against the best practices. But SQLPage offers an alternative that is useful in some scenarios, targeting professional groups like data scientists, analysts, and business intelligence teams who need to build powerful data-centric applications quickly. Those people will use SQLPage in scenarios like:
And while not a framework, do not underestimate its capabilities;you can also read and write HTTP cookies, manage user authentication, handle form submissions and URL parameters. Unsurprisingly that functionality comes in the form of components as well:
Infrastructure wise the underlying magic that makes all that happen, is nicely laied out on the project's Github README page :
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.
Of course there's also a Docker distribution if you don't want to go binary executable.
Behind the scene and as far data storage is concerened, SQLPage works with the following dbms:
In the end I really enjoyed both the concept behind SQLPage as well as its materialization. SQLPage in certain scenarios can prove a very useful tool, as well as enabling you to leverage your sql skills for other purposes than data analysis. Or for simply just having fun!
Summer SALE Kindle 9.99 Paperback $10 off!!
or email your comment to: email@example.com
|Last Updated ( Monday, 21 August 2023 )|