如何创建Emacs SQL缓冲区?
我可以通过执行以下操作手动连接: M-x sql postgres 并键入用户、数据库、主机和服务器 我想做一些类似的事情: (连接foo(用户“me”)(数据库“bar”)(主机“earth”)) 迄今为止的解决办法: 我从sql.el中获取了一些代码并对其进行了更改,以便能够以非交互方式使用它如何创建Emacs SQL缓冲区?,sql,emacs,elisp,Sql,Emacs,Elisp,我可以通过执行以下操作手动连接: M-x sql postgres 并键入用户、数据库、主机和服务器 我想做一些类似的事情: (连接foo(用户“me”)(数据库“bar”)(主机“earth”)) 迄今为止的解决办法: 我从sql.el中获取了一些代码并对其进行了更改,以便能够以非交互方式使用它 (defun sql-create-buffer (profile) "derived from sql-product-interactive in sql.el which is" "co
(defun sql-create-buffer (profile)
"derived from sql-product-interactive in sql.el which is"
"covered by GNU General Public License version 3."
(setq sql-user (cdr (assoc 'user profile))
sql-password (cdr (assoc 'password profile))
sql-server (cdr (assoc 'server profile))
sql-database (cdr (assoc 'database profile)))
(setq product 'postgres) ;;(cdr (assoc 'product profile)))
(when (sql-product-feature :sqli-connect product)
(if (comint-check-proc "*SQL*")
(pop-to-buffer "*SQL*")
;; Connect to database.
(message "Login...")
(funcall (sql-product-feature :sqli-connect product))
;; Set SQLi mode.
(setq sql-interactive-product product)
(setq sql-buffer (current-buffer))
(sql-interactive-mode)
;; All done.
(message "Login...done")
(pop-to-buffer sql-buffer))))
(setq bar-profile '(
(product . "postgres")
(user . "me")
(password . "")
(server . "earth")
(database . "bar")))
我不知道如何处理“product”参数,所以我暂时将其硬编码。
它是sql.el中的postgres
(sql-create-buffer bar-profile)
这个包似乎不打算以非交互方式使用(可能是为了阻止将登录信息写入init文件,这是一个完美的原则) 但是,如果您确实想避免回答这些问题,只需重新定义查询函数,如下所示:
(defun sql-get-login (&rest what)
(setq sql-user "me"
sql-password "secret"
sql-server "localhost"
sql-database "MyDB"))
谢谢我抓取了一些代码并尝试以非交互方式使用它。谢谢。我对Sybase也有类似的问题。我将尝试您的解决方案-我在我的.emacs中有我的irc密码,它与我们的db服务器一起位于防火墙后面。