Hacker News new | ask | show | jobs
by Imustaskforhelp 354 days ago
theoretically there is a go port of sqlite by either using wazero[1] (wasm runtime) and then using sqlite from there or some modernc package[2](i am not sure what this website is except for the sqlite part, so maybe someone can clarify that though) There was also this wrapper of sorts to make the wazero thing genuinely easier to do and it was on r/golang but I don't remember its name but I do think it is semi popular.

[1]wazero:https://wazero.io/ [2]:https://pkg.go.dev/modernc.org/sqlite

1 comments

For modernc you gave the correct link.

For the wazero based driver, it's this package (I'm the author): https://github.com/ncruces/go-sqlite3

Yes btw if I may ask, how does the modernc code actually work and like, if I wanted my code to be minimalist, what should I rather pick?

Also didn't expect that I would be talking to the author of wazero myself haha. I really admire your project.

I'm not the author of wazero, although I've been a maintainer. I'm just the author of the wazero based SQLite driver.

modernc takes the SQLite amalgamation, runs it through the C preprocessor, then converts the result to Go file using the ccgo compiler. Not many further details on how that works: https://www.reddit.com/r/golang/comments/1apreer/comment/kqa...

The Wasm version takes the same SQLite amalgamation and compiles it to portable Wasm using clang/wasi-sdk; the platform specific bits are implemented in Go.

I'm not sure I can say which one is more minimalist with a straight face. One consists of mechanically generated, platform specific, 8MB Go files. The other embeds 1.5MB Wasm BLOB and needs wazero (a big dependency on its own).