I've been using cgo for accessing sqlite for ages, never ever had any trouble. cgo is not remotely as bad as what people might believe. give cgo a go, and you will realize that it saves your time, let you focus on your projects rather than non-senses like how to use stdin/stdout redirection to bypass cgo.
Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
41–50 of 66 posts
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#42Earlier 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.
I don't think cznic's argument is about cross compiling but just being able to avoid cgo. Since some people really don't like cgo.
people are into programming because things can be reasoned, there is logic behind everything. yet there are non-senses that just try to waste people's time & energy by introducing some of their personal briefs backed by no logic into the whole thing.
cross-compiling regular c projects like sqlite should never be an excuse, I don't believe there is anything that can't be scripted when it come to cross-compiling sqlite.
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#43Earlier quoted context omitted.
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.
Very neat! Any idea how its performance compares to the modernc port?
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#44Earlier quoted context omitted.
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.
Pulling a zig isn't going to solve all problems, as the zig cross compiler itself runs into problems fairly often. I already use CC='zig cc -target x86_64-linux-musl' (or whatever the target is) with cgo to cross-compile mattn/go-sqlite3, and relatively recently it simply stopped working[1] and a workaround had to do be added to about every single project of mine using SQLite through cgo. I also once tried to figure…
Personally I’ve had much more portability problems with a lot of the native Go ports of sqlite than I have with mattn’s cgo library.
I author a shell that targets most of the architectures and platforms supported by Go. At the request of some users, I added support for a Go native library because they didn’t want to install a C compilers as well as a Go compiler. I tried a few different sqlite ports (though off hand cannot recall which ones) and they all had massive limitations, like only compiling on Windows and Linux (in one example).
In the end, I gave up and reverted back to the cgo version with the option for other libraries hidden behind a compiler flag.
I found my build pipeline manages just fine with cross compiling and haven’t had any complaints (thus far) with the binaries bar one individual running an ancient version of CentOS.
Maybe I’ve been trying the wrong sqlite ports. But here lies the problem: with cgo I know I’m getting a stable, tested, library. With other ports it’s entirely a lottery with regards to how well maintained and tested it might be. For personal projects that’s a fine risk to take but for any larger open source (or even commercial) projects, that additional uncertainty is a risk that distracts me and the other contributors from working on the core part of the project. And thus defeats the connivance of using 3rd party libraries.
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#45It’s not 100% Go, though. It forks a process that manages the sqlite file. Since the communication with it is written in go, it avoids using cgo.
Wow, that sounds incredibly inefficient!
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#46If 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...
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#47Nice work! It's fun to see other people hacking away at Golang projects. I've been contemplating how to write tests for my own project, and this has given me some ideas.
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#48It’s not 100% Go, though. It forks a process that manages the sqlite file. Since the communication with it is written in go, it avoids using cgo.
Wow, that sounds incredibly inefficient!
That's exactly what I thought, too. But, to my own surprise, it's as fast as CGO solutions, in most cases even faster. You may check here: https://github.com/cvilsmeier/sqinn-go-bench
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#49This is pretty much a os/exec + stdin/stdout redirection library. I've been using cgo for accessing sqlite for ages, never ever had any trouble. cgo is not remotely as bad as what people might believe. give cgo a go, and you will realize that it saves your time, let you focus on your projects rather than non-senses like how to use stdin/stdout redirection to bypass cgo.
Re: Show HN: Sqinn-Go is a Golang library for accessing SQLite databases in pure Go
#50Earlier quoted context omitted.
Wow, that sounds incredibly inefficient!
If you're going to run the database in a background process, you may as well run MySQL or one of its derivatives, or Postgres. More concurrency.
You're right, there are use-cases where SQLite is not appropriate. But nothing beats the ease of installation/backup/maintenance of SQLite compared to server databases like MySQL or Postgres. Another point is development: For unit-tests, I found that initializing a SQLite database for each test-run is much easier (and faster) than having a VM that runs Postgres/MySQL/etc, which I have to spin up and tear down before/after each test run.