New variable to custom sqlite3 executable (#10) (#11)
* emacsql-sqlite3.el(emacsql-sqlite3-executable): New
Zhu Zihao authored 3 years ago
GitHub committed 3 years ago
104 | 104 | "List of all of SQLite's reserved words. |
105 | 105 | https://www.sqlite.org/lang_keywords.html") |
106 | 106 | |
107 | (defgroup emacsql-sqlite3 () | |
108 | "EmacsSQL, sqlite3 backend." | |
109 | :group 'comm) | |
110 | ||
111 | (defcustom emacsql-sqlite3-executable (executable-find "sqlite3") | |
112 | "The path to sqlite3 executable should be used." | |
113 | :group 'emacsql-sqlite3 | |
114 | :type 'file) | |
115 | ||
107 | 116 | (defclass emacsql-sqlite3-connection (emacsql-connection) |
108 | 117 | ((file :initarg :file |
109 | 118 | :type (or null string) |
147 | 156 | ;; Some class don't call superclass's constructor! |
148 | 157 | (cl-defmethod initialize-instance :after |
149 | 158 | ((conn emacsql-sqlite3-connection) _slots) |
150 | (cl-assert (executable-find "sqlite3") nil | |
159 | (cl-assert emacsql-sqlite3-executable nil | |
151 | 160 | "Cannot find executable \"sqlite3\"!") |
152 | 161 | (let* ((file (oref conn file)) |
153 | 162 | (fullfile (if file (list (expand-file-name file)))) |
154 | 163 | (proc (make-process |
155 | 164 | :name "emacsql-sqlite3" |
156 | :command `("sqlite3" "--batch" | |
157 | ;; Use space as separator, | |
158 | ;; which is convenient for `read'. | |
159 | "--list" "--separator" " " | |
160 | ;; Obviously | |
161 | "--nullvalue" "nil" | |
162 | ,@fullfile) | |
165 | :command `(,emacsql-sqlite3-executable | |
166 | "--batch" | |
167 | ;; Use space as separator, | |
168 | ;; which is convenient for `read'. | |
169 | "--list" "--separator" " " | |
170 | ;; Obviously | |
171 | "--nullvalue" "nil" | |
172 | ,@fullfile) | |
163 | 173 | :buffer (generate-new-buffer " *emacsql sqlite*") |
164 | 174 | :noquery t |
165 | 175 | :connection-type 'pipe |