Live data from Hacker News

Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

github.com

21–30 of 66 posts

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#21

If you really want to use SQLite without anything that isn't Go (since this project involves forking and communicating with a non-Go SQLite in a separate process over pipes), there's a Go translation of SQLite's C source. :) https://gitlab.com/cznic/sqlite https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

Yep, confirming that cznic's pure-Go modernc.org/sqlite works great.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#22
post #4

Earlier quoted context omitted.

What’s the case against cgo for SQLite? Just the usual cgo performance overhead? It seems like a pretty good cgo use case: a decent amount of work, which is typically slow enough that cgo overhead isn’t perf critical (because DB usually means disk reads), a super robust and well tested C library with a super well maintained cgo wrapper (mattn).

mattn's sqlite3 is probably the most ideal use case for cgo imaginable. But it can still be annoying to set up cgo to build across many platforms. I think Go should just pull a Zig and just embed a full blown C compiler into go build.

Yeah, once I was on windows and couldn't get cgo sqlite working on a variety of mingw and alike compilers... felt like 90s.

Using this cznic's pure-Go sqlite saved the day.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#23

If you really want to use SQLite without anything that isn't Go (since this project involves forking and communicating with a non-Go SQLite in a separate process over pipes), there's a Go translation of SQLite's C source. :) https://gitlab.com/cznic/sqlite https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

The logic of easy cross compiles doesn't really hold up for go translated SQLite. It depends on a huge pile of per platform support code, of varying quality. If you're only going to target known working platforms, may as well use cgo and a known working cross compiler.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#24
post #9

Earlier quoted context omitted.

To be a bit more specific here: pure Go binaries are trivial to cross-compile and they Just Work™ basically all the time. `GOOS="darwin" GOARCH="arm64" go build .` and you're done. Just iterate over the combinations you care about, they'll all work. As soon as you or a library touches cgo, you have to deal with finding and setting up C cross-compilation tooling for your target(s), dynamic linking details, tons of stu…

Golang works on Plan9. It can even bootstrap itself. A few months ago I was trying to setup some server software on 9Front for giggles and while most stuff worked I couldn't past the Sqlite CGO dependencies.

If you still have that itch to scratch, you can try: https://github.com/ncruces/go-sqlite3

You'll need to use the sqlite3_nolock build tag; concurrent writes will quickly corrupt your database. SetMaxOpenConns(1) is your friend.

But it should work. I'm interested if it doesn't. Feedback appreciated.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#25

If you really want to use SQLite without anything that isn't Go (since this project involves forking and communicating with a non-Go SQLite in a separate process over pipes), there's a Go translation of SQLite's C source. :) https://gitlab.com/cznic/sqlite https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

The logic of easy cross compiles doesn't really hold up for go translated SQLite. It depends on a huge pile of per platform support code, of varying quality. If you're only going to target known working platforms, may as well use cgo and a known working cross compiler.

Does compiling to WASM, using a cgo free WASM runtime, and replacing the OS layer (VFS) with portable Go code count?

That's the elevator pitch (so far) for: https://github.com/ncruces/go-sqlite3/tree/main

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#26
post #25

Earlier quoted context omitted.

The logic of easy cross compiles doesn't really hold up for go translated SQLite. It depends on a huge pile of per platform support code, of varying quality. If you're only going to target known working platforms, may as well use cgo and a known working cross compiler.

Does compiling to WASM, using a cgo free WASM runtime, and replacing the OS layer (VFS) with portable Go code count? That's the elevator pitch (so far) for: https://github.com/ncruces/go-sqlite3/tree/main

Yeah, that's cool. :) although probably a bit slower running through an interpreter.

Modernc/libc takes a rather different approach. It's got some pretty funny files in it. https://gitlab.com/cznic/libc/-/blob/master/musl_openbsd_arm...

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#27
post #25

Earlier quoted context omitted.

Does compiling to WASM, using a cgo free WASM runtime, and replacing the OS layer (VFS) with portable Go code count? That's the elevator pitch (so far) for: https://github.com/ncruces/go-sqlite3/tree/main

Yeah, that's cool. :) although probably a bit slower running through an interpreter. Modernc/libc takes a rather different approach. It's got some pretty funny files in it. https://gitlab.com/cznic/libc/-/blob/master/musl_openbsd_arm...

It is slower.

The WASM runtime https://wazero.io has a compiler on amd64 and arm64 (on Linux, macOS, Windows, and FreeBSD), but the current compiler while very fast (at compiling), is very naive (generates less than optimal code).

An optimizing compiler is currently being developed, and should be released in the coming months. I'm optimistic that this compiler will cover the performance gap between WASM and modernc.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#28
post #4

Earlier quoted context omitted.

What’s the case against cgo for SQLite? Just the usual cgo performance overhead? It seems like a pretty good cgo use case: a decent amount of work, which is typically slow enough that cgo overhead isn’t perf critical (because DB usually means disk reads), a super robust and well tested C library with a super well maintained cgo wrapper (mattn).

mattn's sqlite3 is probably the most ideal use case for cgo imaginable. But it can still be annoying to set up cgo to build across many platforms. I think Go should just pull a Zig and just embed a full blown C compiler into go build.

Didn't it? Isn't that what 5c, 6c, and 8c were.

Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go

#29

If you really want to use SQLite without anything that isn't Go (since this project involves forking and communicating with a non-Go SQLite in a separate process over pipes), there's a Go translation of SQLite's C source. :) https://gitlab.com/cznic/sqlite https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

[deleted]
Post reply on HN