SQLite subprocess working Lassi Kortela (17 Sep 2019 17:50 UTC)
Buffaloed and dogpiled (was: SQLite subprocess working) John Cowan (17 Sep 2019 19:07 UTC)
Re: Buffaloed and dogpiled Lassi Kortela (17 Sep 2019 21:01 UTC)
(missing)
Re: Buffaloed and dogpiled Lassi Kortela (19 Sep 2019 09:09 UTC)
Re: Buffaloed and dogpiled John Cowan (20 Sep 2019 15:25 UTC)

SQLite subprocess working Lassi Kortela 17 Sep 2019 17:50 UTC

We get signal:

$ chez --program test-sqlite.sps
Q: (connect dbname "test.db")
A: (ok)
Q: (execute "create table hello (greeting text)")
A: (ok)
Q: (execute "insert into hello (greeting) values ('Hello world')")
A: (ok)
Q: (execute "select greeting from hello")
A: (ok row "Hello world")
Q: (read-row)
A: (ok)
Q: (disconnect)
A: (ok)
$ chez --program test-sqlite.sps
Q: (connect dbname "test.db")
A: (ok)
Q: (execute "create table hello (greeting text)")
A: (error database "table hello already exists")
Q: (execute "insert into hello (greeting) values ('Hello world')")
A: (ok)
Q: (execute "select greeting from hello")
A: (ok row "Hello world")
Q: (read-row)
A: (ok row "Hello world")
Q: (read-row)
A: (ok)
Q: (disconnect)
A: (ok)

Code at <https://github.com/lassik/scheme-database-temp>. Uses the
binary S-expressions proposed earlier. 1100 lines of C.

The client is for Chez Scheme, but uses no Chez magic. Should be easy to
port. Here's all you need to get going, in addition to the binary sexp
library:
<https://github.com/lassik/scheme-database-temp/blob/master/test-sqlite.sps>.

It took a full workday to get the plumbing going on the C side (by
comparison, the Scheme side took an hour including the binary sexp
library, lol). After that it's a pleasure to develop.

I also looked at libpq, the Postgres C library. It's quite tractable.