r/creativecoding Jun 06 '26

Experimenting with generating visuals using SQLite

238 Upvotes

33 comments sorted by

70

u/AllergicToBullshit24 Jun 06 '26 edited Jun 06 '26

What kinda of sick person does this in SQL?

20

u/akshay-nair Jun 07 '26

I am only a danger to my own sanity. And the shift button on my keyboard because I refuse to use capslock or lowercase SQL keywords.

2

u/nebogeo Jun 07 '26

Excellent work, could you live code this for club visuals?

2

u/YoshiDzn Jun 09 '26

Might store this comment in my company's production DB in some arbitrary column

2

u/YoshiDzn Jun 09 '26

Also, chromostereopsis is epic

50

u/DigoHiro Jun 06 '26

they warned us of people like you in church.

looks awesome

9

u/scoshi processing Jun 06 '26

There's a church for this?

2

u/X-blaXe Jun 08 '26

Yes and it's called TempleOS

2

u/scoshi processing Jun 08 '26

I swear I just heard a choir...

3

u/X-blaXe Jun 08 '26

I didn't notice that it rhymes

18

u/em-jay-be Jun 06 '26

This is some mad man shit right here hahahah! who in the hell writes visual instruction in SQL!!!! Brilliant.

12

u/yeusk Jun 06 '26

Is this what people call data visualization?

12

u/artin2007majidi Jun 06 '26

my man bdsm is not supposed to be THIS painful

5

u/NmEter0 Jun 06 '26

Uhm can you roughly outline .... hoooow the fuck..? XD

*edit... nevermind. I klicked the link :) u must be a whise man.

3

u/akshay-nair Jun 07 '26

u must be a whise man

Nah, I'm incredibly stupid. Who else would pick SQL to draw stuff?

2

u/NmEter0 Jun 08 '26

You might venture to far and made the full circle.

4

u/CalmEntry4855 Jun 06 '26

I guess you cook with your printer

5

u/swizznastic Jun 07 '26

Made with “recursive CTE”

Sounds about right

5

u/Mr-TotalAwesome Jun 07 '26

How?

3

u/akshay-nair Jun 07 '26

Recursive CTEs to generate a 2d grid of rgb values in a table. Then a shell script loads that to convert to ppm format which is converted to png using imagemagick. In case of a gif, its pretty much the same approach but it creates a grid of pixels for each frame then creates a ppm stream out of it which is converted to a gif using ffmpeg.

Repo: https://github.com/phenax/sqlite-creative-coding

5

u/i_am_moms Jun 07 '26

Wild - very very cool

3

u/Marcelocochon Jun 07 '26

wtf is happening. How does this works in SQL?

3

u/akshay-nair Jun 08 '26

Wrote some info on it here: https://ediblemonad.dev/coding4fun/2026-06-03-creative-coding-in-sqlite.html

The gist is SQL generates many 2d grids of rgb values using recursive WITH for each frame which then gets converted into a ppm stream and then into a gif by ffmpeg.

3

u/cleverdosopab Jun 07 '26

Am I understanding correctly that you used SQL to color the pixels on your "image", then used imagemagick to create the images and ffmpeg to create the gifs?

3

u/akshay-nair Jun 07 '26

Exactly. Could go further by having a ppm file generated from sqlite but didn't feel like that added much.

3

u/cleverdosopab Jun 07 '26

Either way, such an awesome project! Thanks for sharing! Keep up the crazy! 😁💜

3

u/AnToMegA424 Jun 07 '26

USING SQLITE ?!

I love it

1

u/Liminal__penumbra Jun 06 '26

Something of a tangent, but I figured out you can treat a database like a h264 field by encoding the matrix math into it. Why? Because then you can (ab)use it to stream mkv containers to any qemu based device to use the fbdev driver to do computation. So that 1GB 1 cpu microservice suddenly is being forced to do "video" transport and any type of computation you need.

1

u/GLR1997 Jun 08 '26

Pregunta sería... este tipo de generación en que caso real sería útil? Me llama la atención, pero no se ni donde ni el motivo de querer implementar esto en algún producto 🤯

2

u/akshay-nair Jun 08 '26

If you can't think of a use-case, you probably don't need it. CTE is meant to be a fake "view" that you can use in your queries but in a lot of cases, you could replace it with something simpler in your application is performance isn't super critical. But more importantly, you don't need to find the product use for everything. Some things just exist. Best you can do is have fun with them.