You can’t connect to a database 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 post by the author, in response to this tweet mocking recruiters asking for the impossible:
Recruiters be like:
We're looking for someone who can connect to the database using CSS.
— Memeloper (@iammemeloper) January 22, 2022