From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id YNugBUmtYmaTVgEAqHPOHw:P1 (envelope-from ) for ; Fri, 07 Jun 2024 08:48:41 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id YNugBUmtYmaTVgEAqHPOHw (envelope-from ) for ; Fri, 07 Jun 2024 08:48:41 +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=C9Ie5cyU; 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=1717742921; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DBU/zlfRCK/vq2XF4MsAQdGUMSHS7KrTUgBzdh+RQqs=; b=gTJmtnX5h3usQ50RRsPDL9yw0cVQlvCpwgwTVTMJEObRd+w9xdF2dVX7Jd3ueXu3/VPndj eXjLdwuM+T9zcUV4oe0cl9oxawPFYWDzQg3rXozvqaEqBEh3Ioj38nw6SIKjEGJjYAtNfK vFbfChH9j01+l9A6PPL0J6SHDZN415KX9Hj3oC/+QAOYeiARvUF+Sk0/F8uQW2/+SwshDS o0sdVixdmbPVZEDgK+cgRcSNlsknxnwTH7KsKWctBpR0LCaADZR+OSYyQYOSzzy2HuRila iii0v3Q5GvFLW97CjZ9mJqb4sp1WzpR2Pww7/wzmU0thX6Vxh7L4CK1o4BpX2g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1717742921; a=rsa-sha256; cv=none; b=LRm+VY9e3XAHop82vWtAWPGDZNL2JAyHYCyDqLVIANPr6AVlxrLjGwDOBRXaNre2JqnGNy b237LjRuyJbkMmrdMmcJa9NBbfskGZBBykhh1WhXgQQ4qukWEJWqaObbl5jemiodGUFhkQ 7M3eIXWF+PiGzSQq1WzIxiU58Nb956Pzym+FRd+SI34SJdl2BUKjq4gAdLnQ/OvxDbEiNF qD9LJrUvVUpEffW6Gv4Gvj8j0XOOWDkv4IwXeQonMpnIcj9vpU9Sq2LY/5Uv9v5Pxygexy U+pRpgjMDtMV1esgySe4Ue/tG32h+YOaQ6vgFsOy/QkWDj/1SZ70MIqcCOA0Qg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=C9Ie5cyU; 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 D25C238E77 for ; Fri, 07 Jun 2024 08:48:40 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFTO1-0000sy-PY; Fri, 07 Jun 2024 02:47:42 -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 1sFTNx-0000rz-Vt for emacs-orgmode@gnu.org; Fri, 07 Jun 2024 02:47:38 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFTNw-00048r-0X for emacs-orgmode@gnu.org; Fri, 07 Jun 2024 02:47:37 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1f4a5344ec7so13675325ad.1 for ; Thu, 06 Jun 2024 23:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717742854; x=1718347654; darn=gnu.org; h=mime-version:message-id:date:address:reply-to:user-agent :organization:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=DBU/zlfRCK/vq2XF4MsAQdGUMSHS7KrTUgBzdh+RQqs=; b=C9Ie5cyUCzeTMdgvesOzHR0f1lbs4achopDCzntG8nSuYrbFNFKvnHhU8kH/G5rL5N 67R5HZ3L004DO0aFcLm2bQVzp4G2do2/jvxBxnBX75RcqG6XkU5sFFijkECd3phkYydt m6lApAlIdJaTubGb43TFLXg4GKMHbDEWlluG5DJSyEw4siEDc1zjxilIhbgW4MrmRbxp wgtp1yaTX5Xf6nRYbJzGABdgmwJKqdHFmXynXEC7V8yrkJHloseWyu3cRFxUqNUCzDO/ d2reZdNEKOWzsdhBYLfanc3IO00LmiCugGXcGV6E/wD9kGvoaRF5KYW8yY6/tSuYpgVz cS9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717742854; x=1718347654; h=mime-version:message-id:date:address:reply-to:user-agent :organization:subject:to:from:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DBU/zlfRCK/vq2XF4MsAQdGUMSHS7KrTUgBzdh+RQqs=; b=qkYbc9rpRNrgvhRYJ1X5GBpJTtxG4OF4Fd5eKDeyXr55XpZZCo+mQPLCShPQudEDaX opJ7eXKYJoo1z0Zp9pWGE7r5Wpam+c28VEYVwmUNKh4xf6k7mWVWOcvKqIQWcYg3wwFt 6++U62fc+WGBryOEpFBBzP0bRAl0rTLygOs3Rq16opE6Jmixpr/m0BFB2qiBE0CdXUwG /sCsg1KhRxlKZKJ77DeNJgoFxnZJpDVXdEzbNHgBuEr7mNcmhJI8ssjkqiDKy4VXAiMm 6oXDdjiUAkZis32c1o//otrkSk1vQ2nJ8xVUK/csnSRbfUR86B2kQg1BH1wuOW0Gnrts rEKg== X-Gm-Message-State: AOJu0YxRk21SalSLRLLE4OaLgsydYmau7VKvKDT3uV6j6VtqQUTITB4o hYvqLAQ7c+Pa5tjPFqz3GkxVllUkTOqU4wHU13VHJR+xsZ288C66WNTrLceJeM4= X-Google-Smtp-Source: AGHT+IFFy2Pem4Z8Y2pJe5H4j31dTHyNVHEuhmPo/AOi7222eBwAPwgs/Bze9P/2qFkTcIKakIttwg== X-Received: by 2002:a17:903:2346:b0:1f6:6a94:76c5 with SMTP id d9443c01a7336-1f6b8ebec7bmr66848925ad.20.1717742853645; Thu, 06 Jun 2024 23:47:33 -0700 (PDT) Received: from mn.cs.uvic.ca (S01065ce93176ea0c.gv.shawcable.net. [24.69.169.164]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6bd7f2839sm26344375ad.266.2024.06.06.23.47.32 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Jun 2024 23:47:32 -0700 (PDT) Received: by mn.cs.uvic.ca (Postfix, from userid 501) id C8E5424EDE0E; Thu, 6 Jun 2024 23:47:31 -0700 (PDT) From: "Daniel M. German" To: emacs-orgmode@gnu.org Subject: Add 'readonly' option to ob-sqlite Organization: turingMachine User-Agent: mu4e 1.12.0; emacs 29.3 Address: dmg@turingmachine.org Date: Thu, 06 Jun 2024 23:47:31 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=dmgerman@gmail.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Spam-Score: -2.34 X-Spam-Score: -2.34 X-Migadu-Queue-Id: D25C238E77 X-Migadu-Scanner: mx11.migadu.com X-TUID: 0P/IGSwhoTLk --=-=-= Content-Type: text/plain hi everybody, 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 This will result in the following error: Runtime error near line 2: attempt to write a readonly database (8) [ Babel evaluation exited with code 1 ] --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-sqlite.el-add-a-new-parameter-called-readonly.patch >From 7df14e4ac2dcdc8fbdf647bff31c9e03f33bd73a Mon Sep 17 00:00:00 2001 From: Daniel M German Date: Thu, 6 Jun 2024 23:34:28 -0700 Subject: [PATCH] lisp/ob-sqlite.el: add a new parameter called readonly. If present, the database is open in read-only mode. This is implemented by passing the parameter -readonly to sqlite --- lisp/ob-sqlite.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el index 96d93b815..b15c4f4d3 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 . :any)) "Sqlite specific header args.") (defun org-babel-expand-body:sqlite (body params) @@ -77,10 +78,10 @@ This function is called by `org-babel-execute-src-block'." (separator (cdr (assq :separator params))) (nullvalue (cdr (assq :nullvalue params))) (headers-p (equal "yes" (cdr (assq :colnames params)))) - (others (delq nil (mapcar + (others (delq nil (mapcar (lambda (arg) (car (assq arg params))) (list :header :echo :bail :column - :csv :html :line :list))))) + :csv :html :line :list :readonly))))) (with-temp-buffer (insert (org-babel-eval @@ -88,7 +89,7 @@ This function is called by `org-babel-execute-src-block'." "%cmd %header %separator %nullvalue %others %csv %db " (list (cons "cmd" org-babel-sqlite3-command) - (cons "header" (if headers-p "-header" "-noheader")) + (cons "header" (if headers-p "-header" "-noheader")) (cons "separator" (if separator (format "-separator %s" separator) "")) (cons "nullvalue" -- 2.45.1 --=-=-= Content-Type: text/plain -- Daniel M. German "A machine --computer-- can only do Lady Lovelace -> what we tell it to do" http://turingmachine.org/ http://silvernegative.com/ dmg (at) uvic (dot) ca replace (at) with @ and (dot) with . --=-=-=--