Database connections as subprocesses Lassi Kortela (14 Sep 2019 07:30 UTC)
Re: Database connections as subprocesses John Cowan (15 Sep 2019 01:06 UTC)
Re: Database connections as subprocesses Lassi Kortela (15 Sep 2019 06:28 UTC)
Re: Database connections as subprocesses John Cowan (15 Sep 2019 23:02 UTC)
Re: Database connections as subprocesses Lassi Kortela (16 Sep 2019 08:22 UTC)
Binary S-expressions Lassi Kortela (16 Sep 2019 17:49 UTC)
(missing)
Re: Binary S-expressions Lassi Kortela (17 Sep 2019 09:46 UTC)
Re: Binary S-expressions Alaric Snell-Pym (17 Sep 2019 11:33 UTC)
Re: Binary S-expressions Lassi Kortela (17 Sep 2019 12:05 UTC)
Re: Binary S-expressions Alaric Snell-Pym (17 Sep 2019 12:23 UTC)
Re: Binary S-expressions Lassi Kortela (17 Sep 2019 13:20 UTC)
Re: Binary S-expressions Lassi Kortela (17 Sep 2019 13:48 UTC)
Re: Binary S-expressions Alaric Snell-Pym (17 Sep 2019 15:52 UTC)
Re: Binary S-expressions hga@xxxxxx (17 Sep 2019 16:25 UTC)
Re: Binary S-expressions rain1@xxxxxx (17 Sep 2019 09:28 UTC)
Re: Binary S-expressions Lassi Kortela (17 Sep 2019 10:05 UTC)
Python library for binary S-expressions Lassi Kortela (17 Sep 2019 21:51 UTC)
R7RS library for binary S-expressions Lassi Kortela (17 Sep 2019 23:56 UTC)
Re: Database connections as subprocesses Alaric Snell-Pym (16 Sep 2019 08:40 UTC)
Re: Database connections as subprocesses Lassi Kortela (16 Sep 2019 09:22 UTC)
Re: Database connections as subprocesses Alaric Snell-Pym (16 Sep 2019 11:28 UTC)
Re: Database connections as subprocesses hga@xxxxxx (16 Sep 2019 13:28 UTC)
Re: Database connections as subprocesses Lassi Kortela (16 Sep 2019 13:50 UTC)
Re: Database connections as subprocesses hga@xxxxxx (17 Sep 2019 13:59 UTC)
Re: Database connections as subprocesses John Cowan (16 Sep 2019 22:41 UTC)
Re: Database connections as subprocesses Lassi Kortela (17 Sep 2019 09:57 UTC)
Re: Database connections as subprocesses Lassi Kortela (17 Sep 2019 10:22 UTC)

Re: Database connections as subprocesses Lassi Kortela 15 Sep 2019 06:27 UTC

> I don't really understand this.  So you send SQL to the driver program,
> which uses the C API to talk to the database?  That means for everything
> except SQLite it's Scheme -> Driver -> DB server -> Driver -> Scheme.

Correct. And the driver lives in the subprocess written in C.

> Also, are you talking to the driver over a socket (TCP or local, doesn't
> matter) or over a pair of pipes?  If the latter, you have to make sure that
> both sides flush frequently, or you will get deadlocks.

I was thinking it would work identically over pipes or a socket. Scheme
would write its request, then flush and wait for the response. The C
side would read the request, write a response, flush, and wait for
another request. Does this simple arrangement cause concern of deadlocks?

A timeout should probably be applied on the Scheme side. Since the
subprocess doesn't have anything else to do, it may as well wait forever
for each request.

> It would also be possible to run the standard CLI client for the database
> using a PTY.  That solves the flushing problem, but you'd need to carefully
> pick an output format (or small set of formats) that all CLI clients can
> produce. that doesn't throw away header names or manifest typing
> information, and unambiguously indicates the end of the result set somehow.

The subprocess would be an alternative to the standard CLI client. The
point would be to have a clean, generic binary interface optimized for
machine parsing. Parsing/quoting into REPLs - that way lies madness...

In a big Scheme with sockets, you'd probably want to write pure-Scheme
Postgres and MySQL clients that talk the native protocol of those
databases directly to the DB server. But for situations where a simple
implementation is important and performance is not an issue, the generic
implementation would do wonders.

I would also put SQLite into a subprocess instead of having in the
Scheme process. A Scheme with FFI that wants really fast SQLite (is
there a substantial speed difference, though?) would embed it in the
Scheme process and talk to it via FFI. The FFI may also be easier to
code. It all depends on the implementation.