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