From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU ELPA] New package: sqlite3 Date: Tue, 21 Mar 2023 12:18:23 +0000 Message-ID: <87ttye5mcw.fsf@posteo.net> 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="15172"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jonas Bernoulli , emacs-devel@gnu.org To: Lynn Winebarger Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 21 13:18:53 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 1peax2-0003hk-F1 for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Mar 2023 13:18:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peawI-0007CX-T6; Tue, 21 Mar 2023 08:18:06 -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 1peawH-0007Bx-16 for emacs-devel@gnu.org; Tue, 21 Mar 2023 08:18:05 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1peawE-0007rG-N8 for emacs-devel@gnu.org; Tue, 21 Mar 2023 08:18:04 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B80BD240691 for ; Tue, 21 Mar 2023 13:18:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1679401080; bh=BqvrfKBsXonEW04BWhy2Pw7acEXb7knguIwDuboVz6Y=; h=From:To:Cc:Subject:Date:From; b=al3gcJ+vFjEhl+b/M6LYieL1caKA8kB8W+8RMFzgxFGryv8DqX9z1TD9u+5kNv7lx vkvKeSNFILS55yg2SeQWRwEfLytNZw6wKtav42Xa2SdMmAxDEeuHzaxaySUTLnWh3t lt9oA1p4wXGmrBmPJHT393S3CPJ81EmNz0HH3fwiQb85F7knwLaCkTho84XntJXKEh 3PBSL5YPtxdkjRGhDZcMwAB8X6EL9Gag4+GfvasYgmIGe3qS8/Ulv13FiPAm9R7SUT DQoGYh28kTub82xKSWiV98x4TVr4/bWh+VCjECzIixRPY28Xu/TOHq54uV+1pZT+fa MN4nFKL7u+gAQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PgrGb6rn7z9rxL; Tue, 21 Mar 2023 13:17:59 +0100 (CET) In-Reply-To: (Lynn Winebarger's message of "Tue, 21 Mar 2023 07:56:25 -0400") Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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:304641 Archived-At: Lynn Winebarger writes: > 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 = wrote: >> >> * 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 bas= ed >> >> > language for constructing SQL queries. I am not looking for anythi= ng >> >> > 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 languag= e: >> > * 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 techn= ique >> >> 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?