From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU ELPA] New package: sqlite3 Date: Tue, 21 Mar 2023 07:56:25 -0400 Message-ID: References: <87cz5o6csk.fsf@bernoul.li> <87mt4swxsw.fsf@posteo.net> <875ybd7mbh.fsf@bernoul.li> <87y1nzb95o.fsf@posteo.net> <87y1nq5pkz.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27424"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jonas Bernoulli , emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 21 12:57:30 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1peacL-0006qZ-OO for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Mar 2023 12:57:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peabY-0007XZ-S1; Tue, 21 Mar 2023 07:56:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1peabX-0007Wm-UY for emacs-devel@gnu.org; Tue, 21 Mar 2023 07:56:39 -0400 Original-Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peabV-0000gz-BG for emacs-devel@gnu.org; Tue, 21 Mar 2023 07:56:39 -0400 Original-Received: by mail-pl1-x62b.google.com with SMTP id le6so15689498plb.12 for ; Tue, 21 Mar 2023 04:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679399796; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TjowPZTRfgLn05w+4/cXoAFnT/GE4Y04R2WtvgOxVqc=; b=cEWVHAG62/g5aidts/Tp88/PDtLgEtcoRQvMvxQEkWMGdtsyjAzk20DwaHnenOY6VL G05J5g8qxyylar/yKx2KAO4GhidvrU/GmP6XlezELCnuZcF+dqTrvCj1VbC7DRms0H1L pfmxvi9DG2KthQst09BNjgZgh0e45Ts30P7fMqpUgiZiMu8nesrUylVIM7orVFBSnsS5 qKRWOuOADe6etzULP4WVetlxh70O3Ew/J7zmG2vks3XPQrdS34M34EAUtOwAnkVnPOk8 ZN4VKOJnGI+pD4GzNrJU6MU/NeRbR7XK/qCrVnCdLgCn+23Tc+EED55tq5MTQwS76gOM Nl2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679399796; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TjowPZTRfgLn05w+4/cXoAFnT/GE4Y04R2WtvgOxVqc=; b=56WRuxWiOOqBuEG4aP2UHwX9K4DJFtTZr9DEqR2HRZSdmBpsueJA84Oi8R81AxR8E+ t7GbfHlm3jGBsXIxwc1cfzhdMt3lXxV0RLpsibZwh+NBLKZ+2vw2WiUDt3RIuti/TRP/ 3i70GPjBl5Rv88z8t7uFoVJd1R6XZcPIYW6Rp3/zj3UEA3tXkSirNlGD9S313KvkXu6V agF2l/W9Pvxteugbg5Ock8F6uAu5y7E1f+5xLww1Cv84Ab0Nv3OpLJ5yxBvapJdw6dx+ N9ZtvjjV0taa4x+VxLbaOjKUZj9X1+qfVC1D8NavW9Who67rkYEFK8bGvLeta7/5A4gD A7mQ== X-Gm-Message-State: AO0yUKU4HnnDZ+Cwxz6wW/ezTfJxBeeTd8KPmkOgsRxnwxuS3xuPMLiY /1/dG/aA9fuBImv5XliyJGdMz09M2kj0OpcXBxs= X-Google-Smtp-Source: AK7set/ClNJLDRF/PdrIGtB9bJ903dyBcRNolKO5wha9sG1RL8b9iqXZCcWa+bmhSxjCW+4ZWNErqDnXJ5Wrr7aMIRc= X-Received: by 2002:a17:902:f7d1:b0:19f:87b5:186d with SMTP id h17-20020a170902f7d100b0019f87b5186dmr659348plw.9.1679399795723; Tue, 21 Mar 2023 04:56:35 -0700 (PDT) In-Reply-To: <87y1nq5pkz.fsf@posteo.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=owinebar@gmail.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304640 Archived-At: On Tue, Mar 21, 2023 at 7:08=E2=80=AFAM Philip Kaludercic wrote: > Lynn Winebarger writes: > > > On Tue, Mar 21, 2023 at 3:22=E2=80=AFAM Jean Louis w= rote: > >> * Philip Kaludercic [2023-03-14 19:17]: > >> > Jonas Bernoulli 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 base= d > >> > language for constructing SQL queries. I am not looking for anythin= g > >> > 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. > > > * Treating code as data and vice-versa is a powerful programming techni= que > > 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). > 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? 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? Lynn