Hacker News new | past | comments | ask | show | jobs | submit login
Extending SQLite with Rust (ricardoanderegg.com)
137 points by philipwhiuk on Sept 5, 2022 | hide | past | favorite | 7 comments



Fun to see this on the front page right after reading this comment:

https://news.ycombinator.com/item?id=32725455


Give the people what they want


Years ago there was a brief vogue for “How X Saved My Startup”.

“How Rust Extensions to SQLite Saved The Blockchain” would be a banger in 2022! Someone do it!


For what it's worth, SQLite works just fine for some blockchains without Rust extensions, e.g. nimbus-eth2[+] uses SQLite with `journal_mode = WAL` to locally persist Beacon Chain data.

Other Beacon Chain client implementations (there are several in wide use) may use SQLite, or something else, I'm not sure at the moment.

[+] https://github.com/status-im/nimbus-eth2#readme


This is great to see. We've been using UDFs with SQLite and .NET for about 3 years now.

With just a little bit of imagination, you can build a very powerful domain-specific language on top of a SQL dialect. There is nothing that says your new SQL functions have to be free from side effects either.

You can also do some crazy stuff with recursive SQL evaluation. I.e. a UDF that executes raw SQL command text, which itself can contain the same invocation. Bonus points if this command text resides in the same database and can reflect/edit itself at runtime...


Yes! I love UDFs in SQLite:

1. I can just write functions in whatever programming language I want.

2. Not having to worry as much about overwriting other UDFs, since different connections can have the same UDF with a different implementation.

3. Having the DB (SQLite) and the function definitions in the same application code and in the same process makes some things a lot easier and flexible.

I actually wrote about that too:

https://ricardoanderegg.com/posts/sqlite-developer-experienc...


> You can also do some crazy stuff with recursive SQL evaluation. I.e. a UDF that executes raw SQL command text, which itself can contain the same invocation. Bonus points if this command text resides in the same database and can reflect/edit itself at runtime...

This is super intriguing, would love to see more details / examples of this.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: