From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id wE8ZGLqOeGZQYwEAe85BDQ:P1 (envelope-from ) for ; Sun, 23 Jun 2024 21:08:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id wE8ZGLqOeGZQYwEAe85BDQ (envelope-from ) for ; Sun, 23 Jun 2024 23:08:10 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=E2jAzvYf; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1719176890; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=vIkVC0c9XzFMs5FAU2CjXGTVTCA8gpD4g5rT+VJDidA=; b=SCXClZLw5vYQc7mMrzyUNXtVXr1JFVe4xvZHkjD8xSm+YStFG1A3x8+jJ8DETY54Nrlkx+ smTYSGo83rEppR/c5TbHavojLtDnsWvOUyf9vI8xR0UKMIKNUDfhSLn28HdZ0wJLCl00Wq dwt06J8wSwrAa1Hl23+JapCPEzMbbCrU4TykqNpkpIM/jgnH57reb+lVK/7Aq7HwVlDZ9O j5BSIabCmJeOlxiAJrSUAJwhjOshYFMC+DcO0NNsr4uYWLuHiP9MOQvfMvDttUFoDVeplg GzyXUt7ergULa4uTWftkA5e7q5eGm2jqYAH1dKG7d3CY0mpbtF7WS9SOHJ2Rpg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1719176890; a=rsa-sha256; cv=none; b=BfEpAsIX6JFUb8PVNMHN+iv1dTCh7FcVvsy3gl6MbW8ugQHsK0a+tGRVaeaqBj0lDwwrvq Qdzlg9TugqAB5zIF+qF4146mqo51WvL6lvSoceg6dvC4FCI2X72CqaMYR9B8ZVI0oP2OhR J150Bt8QllbIk2acVLX1ebxGgwGhNozl0f8np0hxtKYqWLNVJWpQGZeSlrnkX+sjodTE+Y lBJrLUpsOcXFNO13bxggjMticYXHN+y34aX5xTZK+DGTMxXjdXkSZq+s2zRIS544FVxuEm QmOcjRH7t3SsTUhH1qYqNnDEH4/1CYajIftcBotoHgYrtUKsx9JUUoXhI7yKkA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=E2jAzvYf; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 710BD12F97 for ; Sun, 23 Jun 2024 23:08:09 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLUQe-00023Y-SJ; Sun, 23 Jun 2024 17:07:17 -0400 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 1sLUQb-00023A-Td for emacs-orgmode@gnu.org; Sun, 23 Jun 2024 17:07:13 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLUQZ-0005Z2-FB for emacs-orgmode@gnu.org; Sun, 23 Jun 2024 17:07:13 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1f44b45d6abso28160225ad.0 for ; Sun, 23 Jun 2024 14:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719176829; x=1719781629; darn=gnu.org; h=mime-version:message-id:date:address:reply-to:user-agent:references :organization:in-reply-to:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=vIkVC0c9XzFMs5FAU2CjXGTVTCA8gpD4g5rT+VJDidA=; b=E2jAzvYfatFwCMHSaksy6VT6jkmDvJOGmYP5agPYfu6n98I2/0sWduZS8EKq3GsfrX IFY2/Hior7hvMgyFnERfeMFaz0s1R1db8qaGz4RJ2B3uu6ugMUGJ/2XPrc/W5MgVguId zKjISOszP49D89V9WgUJwtEi5WsFEll1ljEBbvFohhxuFtZHTIgJq2Uk3PaPAkKwK2e9 Ki7KQ59snHHV553HjNgungUF527dk6BVqEQqdzztoLHLEpqihUntx+N1rZGBmQDVsjDv YHmOyugsQofB3UFKn2r8UtRtCAlHK33bK73Sk+snLSuFZrW3O3bZp+fPYIuCU0+vmU7a KSAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719176829; x=1719781629; h=mime-version:message-id:date:address:reply-to:user-agent:references :organization:in-reply-to:subject:cc:to:from:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vIkVC0c9XzFMs5FAU2CjXGTVTCA8gpD4g5rT+VJDidA=; b=QJd86upY2FQbAwK8RddSvMYPL7OC+LB6Qrv1B+18VYqdrkxClboR9BtFWpBnwQR1xA VKZzj3dIHC0JqJMQbGkaW40qZxlEpkhnsbtnXU3WDoCOjPdbaqlcvkxU8qZl709qrynV gRquDPN7jfwPyAcsRgmSMDuzswi9gVxGRTdr1FNkMJsAJ2mVQ2BYj0rC3tkZ2DY11Ent 96ujPKc+LHUQDK+cLgn3CvhjJOY133B38JYVj+7pOK4wfVdEo7ax1RV3TyLwmkhX/2O7 hOkQmBbjgOKTadLUhzKLq7DllVbbzJ72qPsqC9txQ1p0thrQfxUdqu7LuWt/lmdoGB9v 33rw== X-Gm-Message-State: AOJu0YzJDN0Mh7o42yyP1Rc0LbUXBL95qdHsD1+yikVrY3TCoJMeu5Xq noVPWDfEpm3NMtP94TnxIN4cuY8Ry8i7MKLx2RuefmzJ8Kp+yhhdkZpuAgkcrJA= X-Google-Smtp-Source: AGHT+IFKl8yE7BHut2YlYHKTi+/YEZbcoy+DSB/l9fai2B4ddSuJ3itIdv27jeFZ04mMpK+NsUhgzA== X-Received: by 2002:a17:902:dac7:b0:1f8:6bc7:e9db with SMTP id d9443c01a7336-1fa1d4fd1d0mr43535735ad.23.1719176828551; Sun, 23 Jun 2024 14:07:08 -0700 (PDT) Received: from mn.cs.uvic.ca (S01065ce93176ea0c.gv.shawcable.net. [24.69.169.164]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9ebbc7b8asm48996205ad.300.2024.06.23.14.07.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 23 Jun 2024 14:07:07 -0700 (PDT) Received: by mn.cs.uvic.ca (Postfix, from userid 501) id 2FC9427DB0E8; Sun, 23 Jun 2024 14:07:07 -0700 (PDT) From: dmg To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: Add 'readonly' option to ob-sqlite In-Reply-To: <87tti494ko.fsf@localhost> (Ihor Radchenko's message of "Fri, 07 Jun 2024 15:04:55 +0000") Organization: turingMachine References: <87tti494ko.fsf@localhost> User-Agent: mu4e 1.12.0; emacs 29.3 Address: dmg@turingmachine.org Date: Sun, 23 Jun 2024 14:07:07 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=dmgerman@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: dmg@turingmachine.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 710BD12F97 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.36 X-Spam-Score: -5.36 X-TUID: xzV47Scn2qao --=-=-= Content-Type: text/plain hi Ihor, Ihor Radchenko writes: > "Daniel M. German" writes: > >> Sometimes I think it is useful to open a DB in readonly mode >> >> eg. to avoid modifying by mistake >> >> This is a patch to ob-sqlite.el to accomplish that >> >> It adds support for opening a sqlite database in readonly only. >> >> It does it by adding a babel parameter readonly. If present, the >> database will be opened in readonly mode. Example: >> >> #+begin_src sqlite :readonly :db /tmp/rip.db >> insert into a values (1,2); >> select * from a; >> #+end_src > > Thanks for the patch! > > May you please change the patch to avoid header arguments without value? > What ob-sqlite doing with "others" is not right because it prevents > setting ":readonly yes" as default header argument and then selectively > disabling it via ":readonly no". > > Also, since you are adding a new feature, please announce it in > etc/ORG-NEWS and document it in > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sqlite.html > (the source code is in > https://git.sr.ht/~bzg/worg/tree/master/item/org-contrib/babel/languages/ob-doc-sqlite.org) I have changed the code. 1. It is enabled only with ":readonly yes. Disabled with any other value 2. Documented change in NEWS 3. Added a patch for Worg Thanks again, --daniel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Documenting-readonly-parameter-for-sqlite-s-babel.patch >From 2949d23c1e06f5cb9c4a07a4b7ec5322b87d8b8e Mon Sep 17 00:00:00 2001 From: Daniel M German Date: Sun, 23 Jun 2024 13:55:57 -0700 Subject: [PATCH] Documenting readonly parameter for sqlite's babel org-contrib/babel/languages/ob-doc-sqlite.org: new option :readonly to ob-sqlite to open the database in readonly mode: --- org-contrib/babel/languages/ob-doc-sqlite.org | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/org-contrib/babel/languages/ob-doc-sqlite.org b/org-contrib/babel/languages/ob-doc-sqlite.org index d7febb0c..d909d24b 100644 --- a/org-contrib/babel/languages/ob-doc-sqlite.org +++ b/org-contrib/babel/languages/ob-doc-sqlite.org @@ -110,6 +110,7 @@ There are 11 SQLite-specific header arguments. SQLite `list' output mode and by the SQLite dot command =.import=. - nullvalue :: a string to use in place of NULL values. + - readonly :: if yes, open the database in readonly mode. *** Variables @@ -252,3 +253,23 @@ where exists (select * from updates where updates.id = bookreview.id); By editing the intermediary table to replace "null" values with a numerical rating, and then running the second source block, the SQLite table will be updated correctly. + +** Open database in read-only mode + +Sometimes it is useful to open the database in readonly mode to make sure no +modifications are made to it. + +#+BEGIN_EXAMPLE +,#+begin_src sqlite :readonly yes :db /tmp/test.db +create table atable(a int, b int); +,#+end_src +#+END_EXAMPLE + +Attempting to run this block will generate the following error: + +#+BEGIN_EXAMPLE +Runtime error near line 2: attempt to write a readonly database (8) +[ Babel evaluation exited with code 1 ] +#+END_EXAMPLE + + -- 2.45.2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-sqlite-Added-ability-to-open-a-database-in-readon.patch >From 0491d3a672e7a99142da6ac6ade26666ae809b04 Mon Sep 17 00:00:00 2001 From: Daniel M German Date: Sun, 23 Jun 2024 13:48:57 -0700 Subject: [PATCH] ob-sqlite: Added ability to open a database in readonly mode Added option :readonly to ob-sqlite. lisp/ob-sqlite.el: When :readonly=true the database is opened in readonly mode. For example: #+begin_src sqlite :db /tmp/rip.db :readonly yes :exports both create table rip(a,b); #+end_src This results in an error such as: Runtime error near line 2: attempt to write a readonly database (8) etc/ORG-NEWS: documented changes --- etc/ORG-NEWS | 18 ++++++++++++++++++ lisp/ob-sqlite.el | 10 +++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 1252bbca1..357c41bb2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -51,6 +51,24 @@ all the references are resolved in the generated png. # This also includes changes in function behavior from Elisp perspective. +*** ob-sqlite: Added ability to open a database in readonly mode + +Added option :readonly to ob-sqlite. + +When :readonly=true the database is opened in readonly mode. For example: + +#+begin_src sqlite :db /tmp/rip.db :readonly yes :exports both +create table rip(a,b); +#+end_src + +This results in an error such as: + +#+begin_example +Runtime error near line 2: attempt to write a readonly database (8) +[ Babel evaluation exited with code 1 ] +#+end_example + + ** Miscellaneous * Version 9.7 diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el index 96d93b815..e125d927c 100644 --- a/lisp/ob-sqlite.el +++ b/lisp/ob-sqlite.el @@ -52,7 +52,8 @@ (line . :any) (list . :any) (separator . :any) - (nullvalue . :any)) + (nullvalue . :any) + (readonly-p . :any)) "Sqlite specific header args.") (defun org-babel-expand-body:sqlite (body params) @@ -76,7 +77,8 @@ This function is called by `org-babel-execute-src-block'." (db (cdr (assq :db params))) (separator (cdr (assq :separator params))) (nullvalue (cdr (assq :nullvalue params))) - (headers-p (equal "yes" (cdr (assq :colnames params)))) + (headers-p (equal "yes" (cdr (assq :colnames params)))) + (readonly-p (equal "yes" (cdr (assq :readonly params)))) (others (delq nil (mapcar (lambda (arg) (car (assq arg params))) (list :header :echo :bail :column @@ -85,7 +87,7 @@ This function is called by `org-babel-execute-src-block'." (insert (org-babel-eval (org-fill-template - "%cmd %header %separator %nullvalue %others %csv %db " + "%cmd %header %separator %nullvalue %others %csv %readonly %db " (list (cons "cmd" org-babel-sqlite3-command) (cons "header" (if headers-p "-header" "-noheader")) @@ -103,6 +105,8 @@ This function is called by `org-babel-execute-src-block'." (member :html others) separator) "" "-csv")) + (cons "readonly" + (if readonly-p "-readonly" "")) (cons "db" (or db "")))) ;; body of the code block (org-babel-expand-body:sqlite body params))) -- 2.45.2 --=-=-= Content-Type: text/plain -- Daniel M. German ""Geek" is a badge of honor." Eric Schmidt, CEO of Novell http://turingmachine.org/ http://silvernegative.com/ dmg (at) uvic (dot) ca replace (at) with @ and (dot) with . --=-=-=--