Connect to a DB from CSS

You can’t connect to a DB from within CSS, Right? Or can you? Leveraging Houdini and SQL.js — which is SQLite compiled to JavaScript to serve as in-memory DB — you can. Using some Custom Properties, you can pass in queries to be executed. .query-display { background: paint(sql-css); } main { –sql-query: SELECT * FROM …


This content originally appeared on Bram.us and was authored by Bramus!

You can’t connect to a DB from within CSS, Right? Or can you?

Leveraging Houdini and SQL.js — which is SQLite compiled to JavaScript to serve as in-memory DB — you can. Using some Custom Properties, you can pass in queries to be executed.

.query-display {
  background: paint(sql-css);
}

main {
  --sql-query: SELECT * FROM genre;
  --sql-database: url(...);
}

Hahaha, just brilliant! 😅

Yes, I can connect to a DB in CSS →
SQL CSS →

Note that this is a tongue-in-cheek by the author, in response to this tweet mocking recruiters:


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2022-02-07T17:06:46+00:00) Connect to a DB from CSS. Retrieved from https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/

MLA
" » Connect to a DB from CSS." Bramus! | Sciencx - Monday February 7, 2022, https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/
HARVARD
Bramus! | Sciencx Monday February 7, 2022 » Connect to a DB from CSS., viewed ,<https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/>
VANCOUVER
Bramus! | Sciencx - » Connect to a DB from CSS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/
CHICAGO
" » Connect to a DB from CSS." Bramus! | Sciencx - Accessed . https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/
IEEE
" » Connect to a DB from CSS." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/. [Accessed: ]
rf:citation
» Connect to a DB from CSS | Bramus! | Sciencx | https://www.scien.cx/2022/02/07/connect-to-a-db-from-css/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.