Is there SQLite wrapper for elisp?
If not, is it a good idea to call python code that takes control of SQLite through start-process or something? Is there better way to use SQLite from elisp?
Is there SQLite wrapper for elisp?
If not, is it a good idea to call python code that takes control of SQLite through start-process or something? Is there better way to use SQLite from elisp?
Emacs wiki is your friend, there lies a couple of links to a couple of tools for sqlite.
Emacs WIki SQLite, the first link is probably the one you're looking for: handling the interaction with the database: sql-mode.
From Trey Jackson's starting link, there seems to be a tutorial on how to build a programmatic interface for elisp to an inferior-process sqlite, e.g. sqlite-query<f>
. It is based on screen-scraping a comint buffer just for this purpose (e.g. not reusing sql.el). The following is an incomplete example copied from that reference.
;; this is emacs lisp code
(defun sqlite-query ( sql-command )
(set-buffer sqlite-output-buffer) ;1
(erase-buffer) ;2
(comint-redirect-send-command-to-process
sql-command
sqlite-output-buffer
(get-buffer-process sqlite-process-buffer) nil) ;3
(accept-process-output
(get-buffer-process sqlite-process-buffer)
1) ;need to wait to obtain results
(let* ((begin (goto-char (point-min))) ;4
(end (goto-char (point-max)))
(num-lines (count-lines begin end))
(counter 0)
(results-rows ()))
(goto-char (point-min))
(while ( < counter num-lines)
(setq results-rows (cons (chomp (thing-at-point 'line)) results-rows))
(forward-line)
(setq counter (+ 1 counter)))
(car `(,results-rows))))
Unfortunately there doesn't look like there is anything off-the-shelf there, but perhaps it is a good approach and probably better than trying to use yet another intermediate language.
(Aside, I find that example of connecting sqlite with emacs' Widget GUI interface to be intriguing.)