←back to thread

200 points dcu | 8 comments | | HN request time: 1.537s | source | bottom
Show context
jasonthorsness ◴[] No.44456854[source]
CSV database is interesting; probably the most trivially-debuggable a database can possibly be. Although why not SQLite? CSV is not very resistant corruption if host crashes midway through a write.
replies(1): >>44456886 #
ncruces ◴[] No.44456886[source]
No dependencies apart from the standard library is my guess.
replies(1): >>44457013 #
1. christina97 ◴[] No.44457013[source]
Go doesn’t have sqlite in the stdlib?
replies(1): >>44457053 #
2. jasonthorsness ◴[] No.44457053[source]
It doesn’t and using the standard 3rd party package requires compiling with CGO which is a pain for cross-platform :(
replies(3): >>44457109 #>>44457120 #>>44463472 #
3. Imustaskforhelp ◴[] No.44457109[source]
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

replies(1): >>44457411 #
4. kassner ◴[] No.44457120[source]
There is a CGO-free package for the basics: https://gitlab.com/cznic/sqlite

Not 100% drop-in though. I’ve hit some snags around VFS support.

5. ncruces ◴[] No.44457411{3}[source]
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

replies(1): >>44461438 #
6. Imustaskforhelp ◴[] No.44461438{4}[source]
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.

replies(1): >>44463870 #
7. jpc0 ◴[] No.44463472[source]
Define cross platform here?

I’ve heard this complaint but have yet to have an issue deploying to Linux/MacOS/Windows on arm or x86 using CGO backed libraries.

Maybe if you truly are targeting some niche platform but then you likely have some other issues to contend with and where are you deploying to?

8. ncruces ◴[] No.44463870{5}[source]
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).