是否有针对elisp的SQLite包装器?
如果不是,那么调用python代码来通过启动进程或其他方式控制SQLite是不是一个好主意?有没有更好的方法从elisp中使用SQLite?
发布于 2010-08-26 21:01:09
在Trey Jackson的起始链接中,似乎有一个关于如何构建 a programmatic interface for elisp to an inferior-process sqlite的教程,例如sqlite-query<f>。它是基于屏幕抓取comint buffer来实现这个目的(例如不重用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))))不幸的是,看起来并没有什么现成的东西,但可能是it is a good approach,而且可能比尝试使用另一种中间语言要好。
(另外,我发现将sqlite与emacs的Widget GUI接口连接的示例很有趣。)
发布于 2010-08-26 13:12:42
Emacs wiki是你的朋友,有几个链接指向sqlite的几个工具。
Emacs WIki SQLite,第一个链接可能就是您要找的:处理与数据库的交互:sql-mode。
https://stackoverflow.com/questions/3571574
复制相似问题