[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 70e95655df 8/9: emacsql-sqlite-default-connection:
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 70e95655df 8/9: emacsql-sqlite-default-connection: New function |
Date: |
Wed, 22 Feb 2023 14:59:08 -0500 (EST) |
branch: elpa/emacsql
commit 70e95655dfc3c1a59e26a6562e8b025216c2e49d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
emacsql-sqlite-default-connection: New function
---
emacsql-sqlite-common.el | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/emacsql-sqlite-common.el b/emacsql-sqlite-common.el
index 4226ccaa91..378df3e6d5 100644
--- a/emacsql-sqlite-common.el
+++ b/emacsql-sqlite-common.el
@@ -85,6 +85,31 @@ ERRSTR). Also see https://www.sqlite.org/rescode.html.")
;;; Utilities
+(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,
+then try to compile it. Signal an error if no connection class
+can be used."
+ (or (and (fboundp 'sqlite-available-p)
+ (sqlite-available-p)
+ (require 'emacsql-sqlite-builtin)
+ 'emacsql-sqlite-builtin-connection)
+ (and (boundp 'module-file-suffix)
+ module-file-suffix
+ (and (with-demoted-errors
+ "Cannot use `emacsql-sqlite-module-connection': %S"
+ (require 'emacsql-sqlite-module))
+ 'emacsql-sqlite-module-connection))
+ (and (require 'emacsql-sqlite)
+ (boundp 'emacsql-sqlite-executable)
+ (or (file-exists-p emacsql-sqlite-executable)
+ (with-demoted-errors
+ "Cannot use `emacsql-sqlite-connection': %S"
+ (and (fboundp 'emacsql-sqlite-compile)
+ (emacsql-sqlite-compile 2))))
+ 'emacsql-sqlite-connection)
+ (error "EmacSQL could not find or compile a back-end")))
+
(defun emacsql-sqlite-list-tables (connection)
"Return a list of the names of all tables in CONNECTION.
Tables whose names begin with \"sqlite_\", are not included
- [nongnu] elpa/emacsql updated (f0249f655f -> 497971121a), ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql 7a725e1910 2/9: Add new library emacsql-sqlite-common, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql 8d111e4dcd 6/9: emacsql-sqlite-dump-database: New function, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql b4d7efac4d 7/9: emacsql-sqlite-restore-database: New function, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql 0bcf526c48 1/9: Fix how class documentation is provided, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql d61f674b64 4/9: emacsql--sqlite-base: Use nil as :initform of file slot, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql ad3483c97c 5/9: emacsql-sqlite-list-tables: New function, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql 497971121a 9/9: emacsql-sqlite-dump-database: Override output file unless versioned, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql b33073257e 3/9: Use common base class for all SQLite connection classes, ELPA Syncer, 2023/02/22
- [nongnu] elpa/emacsql 70e95655df 8/9: emacsql-sqlite-default-connection: New function,
ELPA Syncer <=