unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Lynn Winebarger <owinebar@gmail.com>
Cc: Jonas Bernoulli <jonas@bernoul.li>,  emacs-devel@gnu.org
Subject: Re: [NonGNU ELPA] New package: sqlite3
Date: Tue, 21 Mar 2023 12:18:23 +0000	[thread overview]
Message-ID: <87ttye5mcw.fsf@posteo.net> (raw)
In-Reply-To: <CAM=F=bAhKgpmYdF0pftjECBScrb5+Zv6OrvKHKeXnF_iFXQzxw@mail.gmail.com> (Lynn Winebarger's message of "Tue, 21 Mar 2023 07:56:25 -0400")

Lynn Winebarger <owinebar@gmail.com> writes:

> On Tue, Mar 21, 2023 at 7:08 AM Philip Kaludercic <philipk@posteo.net> wrote:
>> Lynn Winebarger <owinebar@gmail.com> writes:
>>
>> > On Tue, Mar 21, 2023 at 3:22 AM Jean Louis <bugs@gnu.support> wrote:
>> >> * Philip Kaludercic <philipk@posteo.net> [2023-03-14 19:17]:
>> >> > Jonas Bernoulli <jonas@bernoul.li> writes:
>> >> >
>> >> > >> Do you have a link to the package you are talking about?
>> >> > >
>> >> > > Ups, here you go: https://github.com/pekingduck/emacs-sqlite3-api
>> >> >
>> >> > Would you happen to know if there is some rx-like, s-expression based
>> >> > language for constructing SQL queries.  I am not looking for anything
>> >> > generic, just a way to avoid writing long strings.
>> >>
>> >> While such packages exists, for me I do not find them usable as then I
>> >> have to forget about the SQL and learn about the new Emacs Lisp
>> >> structure that is to correspond to SQL. I see personally no benefit in
>> >> that.
>> >
>> > There are a couple of good reasons to use an sexpr-based query language:
>> > * Avoiding sql injection issues by putting all the boilerplate for
>> > interpolating data into queries into a macro expander
>>
>> To be fair, this is not a concern because SQLite supports parameterised
>> queries:
>>
>>   (sqlite-execute db "insert into foo values (?, ?)" '("bar" 2))
>
> That's a pretty limited notion of interpolating data into code.  Using
> metadata stored in tables and systematically generating queries from
> that metadata is a pretty standard technique even among SQL
> programmers that aren't otherwise inclined to writing recursive macros
> to implement DSLs.

I cannot say, for my intents this has always been enough.

>> > * Treating code as data and vice-versa is a powerful programming technique
>>
>> Not sure about this.... Strings are data too, but neither the SQL
>> statements or the regular expressions are (Elisp) code.
>
> Are lisp macros written in terms of string interpolation?  If there
> are no other types of data than strings, fine, but that's not really
> the case - machine instructions have different operations for
> integers/floats/pointers, a good programming abstraction will reflect
> that.  If the underlying machine used strings to represent numbers and
> arithmetic operations took two numeric strings and produced another
> numeric string, maybe there'd be a case to be made (although the first
> point above still mitigates against it).

I really have no idea what you are getting at.

>> To me the
>> advantage of something like `rx' is that I can insert comments and make
>> use of regular indentation.  Then again, it would also be possible to
>> provide specialised SQLite wrappers (sqlite-insert, sqlite-update, ...)
>> instead of taking a `rx' like approach to generating strings.
>>
>> > The real power of embedding sqlite in elisp will come when sqlite data
>> > structures can be used as efficient representations of sets and
>> > relations in lisp code.  Eventually, I would also expect to see
>> > mutually recursive code enabled, with "virtual table" modules for
>> > emacs data structures so they can be transparently used in sql code,
>> > along with sql functions written in lisp.  For example, you might
>> > create a table from lisp data using a select statement rather than
>> > executing a large number of insert statements.  In-memory databases
>> > would not be unusual, and should be dumpable objects.
>>
>> What is the point of using a in-memory database if you want to dump it?
>
> It's just another data structure at that point, so why wouldn't I want
> to be able to include it in my pdmp file?  Why would I want to make my
> internal data structure available as a separate file, or manage
> creating and tracking those files?

My bad, I did not understand that you were talking about dumping in
terms of what temacs does.  Perhaps you could be more clear if you have
a specific example of what you think a in-memory database could be used
for when dumped along with Emacs?

> Maybe having a separate primitive type for a "table" with named
> columns that happens to be represented with a sqlite_statement would
> make the abstraction clearer?



  reply	other threads:[~2023-03-21 12:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 10:17 [NonGNU ELPA] New package: sqlite3 Jonas Bernoulli
2023-03-04 11:39 ` Philip Kaludercic
2023-03-06 18:43   ` Jonas Bernoulli
2023-03-14 16:16     ` Philip Kaludercic
2023-03-14 22:46       ` Jonas Bernoulli
2023-03-15  8:05         ` Philip Kaludercic
2023-03-21  6:51       ` Jean Louis
2023-03-21 10:55         ` Lynn Winebarger
2023-03-21 11:08           ` Philip Kaludercic
2023-03-21 11:56             ` Lynn Winebarger
2023-03-21 12:18               ` Philip Kaludercic [this message]
2023-03-21 13:04                 ` Lynn Winebarger
2023-03-21 16:53                   ` Philip Kaludercic
2023-03-21 21:00                     ` Tomas Hlavaty
2023-04-07  4:53                       ` Jean Louis
2023-03-21 23:58                     ` Lynn Winebarger
2023-03-22  8:10                       ` Philip Kaludercic
2023-03-22 15:05                         ` Lynn Winebarger
2023-03-23  0:07                           ` Lynn Winebarger
2023-03-21 20:42             ` Tomas Hlavaty
     [not found]               ` <875yatn70c.fsf@posteo.net>
2023-03-21 22:46                 ` Tomas Hlavaty
2023-03-22  8:00                   ` Philip Kaludercic
2023-03-21 20:36         ` Tomas Hlavaty
2023-04-07  5:17           ` Jean Louis
2023-03-06  5:08 ` Richard Stallman
2023-03-14 14:36   ` Jonas Bernoulli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttye5mcw.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=emacs-devel@gnu.org \
    --cc=jonas@bernoul.li \
    --cc=owinebar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).