emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 415dbfd846 2/2: emacsql-sqlite-open: New function


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 415dbfd846 2/2: emacsql-sqlite-open: New function
Date: Tue, 28 Feb 2023 05:59:10 -0500 (EST)

branch: elpa/emacsql
commit 415dbfd846f46d921a70a351695f0d0e8f75da35
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    emacsql-sqlite-open: New function
---
 emacsql-sqlite-common.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/emacsql-sqlite-common.el b/emacsql-sqlite-common.el
index 40c3662632..3283fc256f 100644
--- a/emacsql-sqlite-common.el
+++ b/emacsql-sqlite-common.el
@@ -85,6 +85,23 @@ ERRSTR).  Also see https://www.sqlite.org/rescode.html.";)
 
 ;;; Utilities
 
+(defun emacsql-sqlite-open (file &optional debug)
+  "Open a connected to the database stored in FILE using an SQLite back-end.
+
+Automatically use the best available back-end, as returned by
+`emacsql-sqlite-default-connection'.
+
+If FILE is nil, use an in-memory database.  If optional DEBUG is
+non-nil, log all SQLite commands to a log buffer, for debugging
+purposes."
+  (let* ((class (emacsql-sqlite-default-connection))
+         (connection (make-instance class :file file)))
+    (when (eq class 'emacsql-sqlite-connection)
+      (set-process-query-on-exit-flag (oref connection handle) nil))
+    (when debug
+      (emacsql-enable-debugging connection))
+    connection))
+
 (defun emacsql-sqlite-default-connection ()
   "Determine and return the best SQLite connection class.
 If a module or binary is required and that doesn't exist yet,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]