Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt

From: Michael Mauger <[email-masked]>
Date: Mon, 19 May 2025 01:36:05 +0000

On Saturday, February 15th, 2025 at 4:25 PM, Ihor Radchenko <[email-masked]> wrote:

> Ihor Radchenko [email-masked] writes:
> 
> > May you please post the patch on Emacs bug tracker? (M-x
> > submit-emacs-patch) and X-Debbugs-CC me?
> > That way, we get the Emacs maintainers involved into the discussion.
> 
> 
> The patch is in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76025
> 
> There are no major objections to the patch other than the maintainer
> being interested to coordinate ob-sql improvements and sql.el
> changes.
> 
> I am CCing the feature request thread so that we can discuss everything
> together.
> 
> May you please update your latest patch for ob-sql.el, converting it
> into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes
> to sql.el?
> 
> --
> Ihor Radchenko // yantar92,

I'm sorry to be late to this party, but this is the first real description of what features were needed from sql.el. 

Based on what I'm seeing, I think the feature you want is already present (but can be made simpler for you to use). And the support for the empty name sqlite database is similar to in-memory databases that I have in a local development branch that hasn't been merged/pushed.

The `sql-connect' machinery suppresses prompts for parameters in the connection alist already. There are two ways to take advantage of that: install connection parameters in `sql-connection-alist' with an ob-sql specific connection name and then `sql-connect' to it, or allow `sql-connect' to be called with a complete connection alist entry in place of the connection name. I think the latter option is a better choice, and easy to incorporate into the code; the former option would be a total ob-sql solution. Id be cautious modifying `sql-product-interactive' directly since so much passes thru there and `sql-connect' already implements the logic you want around it.

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)?

I am looking to cleanup sql.el (some of it's code is 20+ years old) and has some very broken pieces in it. Changing it to simplify support from treesit and eglot exposes rough edges that will break things for existing users. `sql-connect' is the intended interface for programmatic invocation of SQL-interactive processes.

--
[email-masked] // FSF and SFConservancy // GNU Emacs sql.el maintainer