SQLite和elisp?

pro*_*eek 4 sqlite elisp

是否有针对elisp的SQLite包装器?

如果没有,调用通过启动进程控制SQLite的python代码是一个好主意吗?有更好的方法从elisp使用SQLite吗?

Tre*_*son 6

Emacs wiki是你的朋友,有几个链接到几个sqlite工具.

Emacs WIki SQLite,第一个链接可能是您正在寻找的链接:处理与数据库的交互:sql-mode.


piy*_*iyo 6

Trey Jackson的起始链接,似乎有一个教程,介绍如何为elisp 构建 一个程序化界面到一个劣质过程sqlite,例如sqlite-query<f>.它基于屏幕抓取comint缓冲区,仅用于此目的(例如,不重用sql.el).以下是从该引用复制的不完整示例.

;; 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))))
Run Code Online (Sandbox Code Playgroud)

不幸的是,看起来没有任何现成的东西,但也许它是一种很好的方法,可能比尝试使用另一种中间语言更好.

(除此之外,我发现连接sqlite和emacs的Widget GUI界面的例子很有趣.)

  • 我写了一个[针对Emacs Lisp的小型SQLite包装器](http://www.jasonfruit.com/page/emacs_sqlite_and_widgets)以响应此处的代码. (2认同)