Subject: Re: [PATCH] ob-sql: session

From: Phil Estival <[email-masked]>
Date: Mon, 16 Jun 2025 14:19:18 +0200

* [2025-06-15 20:59 +0000] Michael Mauger <[email-masked]>:
> On Sunday, June 15th, 2025 at 3:16 PM, Phil Estival <[email-masked]> wrote:
>
>> I also took good note of Michael's remarks.
>> The attached series of patches will work
>> without any modification to sql.el. I'll introduce later a local
>> `sql-connection' bound to the session name. In the absence of it,
>> sessions will work, but will ask to confirm provided connection
>> parameter upon establishing connection.
>>
>
> Wouldn't the SQLi buffer created by sql-connect be the session?

Yes, right.  The session is an identifier name, the buffer's name is
build on that name but the connection's name can be shared among
sessions.

> At least in sql.el, when it uses either sql-connect or
> sql-product-interactive, all the buffers are scanned to for the
> desired connection settings and switch to the matching buffer rather
> than creating a new buffer.

Aren't they opened in parallel, one connection each, with the same
connection parameters ?

`org-babel-sql-session-connect' uses `sql-product-interactive' with a
buffer name as argument. Different sessions are run in different sql
interactive buffers, yet they have the same connection settings.

> I am trying to cleanup sql.el 2.x before I do a more significant
> rewrite for sql.el 3.0.  The update will include sql-add-connection
> which cleanly adds an entry to sql-connection-alist and the ability to
> call sql-connect with with the connection settings themselves rather
> than the connection name.  Hopefully those will simplify the
> integrations that you need.

Fine.

> And please let me know if you are not getting the behavior you want,
> or if you are working around something that I ought to look at....

* [2025-05-19 01:36 +0000] Michael Mauger <[email-masked]>:
> For sqlite, I've added support for an in-memory database using the
> name ":memory:" in my local repo. Obviously an empty name indicates a
> temporary database which may be in-memory, or if larger, in temporary
> disk space. I'll take a look at adding support for temporary databases
> but I'm not a huge fan of an empty database name option. Maybe support
> ":tempdb:" (or similar)?

The message sqlite3 displays on the welcoming message is:
"Connected to a transient in-memory database.", so perhaps
the proper word is ":in-memory:" ?

While the empty string as database name should IMHO be avoided, the nil
parameter must still be allowed:

"If no database name is supplied, the ATTACH sql command can be used to
attach to existing or create new database files.  ATTACH can also be
used to attach to multiple databases within the same interactive
session.  This is useful for migrating data between databases, possibly
changing the schema along the way."

Cheers,
--
Phil Estival