2
2
3
3
4
4
(require 'emacsql )
5
+ ; ; REVIEW: is this require needed?
6
+ ; ; emacsql-sqlite provides a common interface to an emacsql SQLite backend (e.g. emacs-sqlite-builtin)
7
+ ; ; not to be confused with a backend itself named emacsql-sqlite that existed in emacsql < 4.0.
8
+ (require 'emacsql-sqlite )
5
9
(require 'dash )
6
10
7
11
(defcustom paw-db-file
10
14
:group 'paw
11
15
:type 'file )
12
16
13
- (defcustom paw-db-connector (if (and (progn
14
- (require 'emacsql-sqlite-builtin nil t )
15
- (functionp 'emacsql-sqlite-builtin ))
16
- (functionp 'sqlite-open ))
17
- 'sqlite-builtin
18
- 'sqlite )
19
- " The database connector used by paw.
20
- This must be set before `paw' is loaded. To use an alternative
21
- connector you must install the respective package explicitly.
22
- The default is `sqlite' , which uses the `emacsql-sqlite' library
23
- that is being maintained in the same repository as `emacsql'
24
- itself.
25
- If you are using Emacs 29, then the recommended connector is
26
- `sqlite-builtin' , which uses the new builtin support for SQLite.
27
- You need to install the `emacsql-sqlite-builtin' package to use
28
- this connector.
29
- If you are using an older Emacs release, then the recommended
30
- connector is `sqlite-module' , which uses the module provided by
31
- the `sqlite3' package. This is very similar to the previous
32
- connector and the built-in support in Emacs 29 derives from this
33
- module. You need to install the `emacsql-sqlite-module' package
34
- to use this connector.
35
- For the time being `libsqlite3' is still supported. Do not use
36
- this, it is an older version of the `sqlite-module' connector
37
- from before the connector and the package were renamed.
38
- For the time being `sqlite3' is also supported. Do not use this.
39
- This uses the third-party `emacsql-sqlite3' package, which uses
40
- the official `sqlite3' cli tool, which is not intended
41
- to be used like this. See https://nullprogram.com/blog/2014/02/06/."
42
- :group 'wallabag
43
- :type '(choice (const sqlite)
44
- (const sqlite-builtin)
45
- (const sqlite-module)
46
- (const :tag " libsqlite3 (OBSOLETE)" libsqlite3)
47
- (const :tag " sqlite3 (BROKEN)" sqlite3)))
48
-
49
17
50
18
(defvar paw-db-connection nil
51
19
" The EmacSQL database connection." )
@@ -55,31 +23,6 @@ to be used like this. See https://nullprogram.com/blog/2014/02/06/."
55
23
(defvar paw-db-newp nil )
56
24
(defvar paw-db-update-p nil )
57
25
58
- (defun paw-db--conn-fn ()
59
- " Return the function for creating the database connection."
60
- (cl-case paw-db-connector
61
- (sqlite
62
- (progn
63
- (require 'emacsql-sqlite )
64
- #'emacsql-sqlite ))
65
- (sqlite-builtin
66
- (progn
67
- (require 'emacsql-sqlite-builtin )
68
- #'emacsql-sqlite-builtin ))
69
- (sqlite-module
70
- (progn
71
- (require 'emacsql-sqlite-module )
72
- #'emacsql-sqlite-module ))
73
- (libsqlite3
74
- (progn
75
- (require 'emacsql-libsqlite3 )
76
- #'emacsql-libsqlite3 ))
77
- (sqlite3
78
- (progn
79
- (require 'emacsql-sqlite3 )
80
- #'emacsql-sqlite3 ))))
81
-
82
-
83
26
(defun paw-db ()
84
27
" Connect or create database.
85
28
serverp:
@@ -95,7 +38,7 @@ serverp:
95
38
(unless (and paw-db-connection (emacsql-live-p paw-db-connection))
96
39
(unless (file-exists-p (concat user-emacs-directory " .cache/" ))
97
40
(make-directory (concat user-emacs-directory " .cache/" )))
98
- (setq paw-db-connection (funcall (paw-db--conn-fn) paw-db-file))
41
+ (setq paw-db-connection (emacsql-sqlite-open paw-db-file))
99
42
100
43
; ; create items table
101
44
(emacsql paw-db-connection [:create-table :if-not-exists items ([(word STRING :primary-key )
0 commit comments