Home  >  Article  >  Database  >  Emacs sql-mode 自动连接数据库 (当前仅支持MySQL)_MySQL

Emacs sql-mode 自动连接数据库 (当前仅支持MySQL)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:11:061511browse

Emacs 的 sql-mode 能够将emacs作为一个数据库客户端来使用,用户可以打开一个.sql 文件,连接数据库并执行sql文件中部分SQL指令。
这个插件不方便的地方是每次建立数据库连接的时候都需要先选择数据库产品 (nysql, DB2, oracle …), 并且输入一些连接信息才可以打开SQLi buffer。 插件 emacs-sqlhat 能够让用户在sql文件中设置这些信息,通过一条命令就可以直接打开SQLi buffer。

安装

可以在github上下载 emacs-sqlhat : https://github.com/ChanningBJ/emacs-sqlhat
首先安装python部分:

python setup.py install

然后在 .emacs 中加上这两行

(add-to-list 'load-path  "/path/to/emacs-sqlhat")(require 'sqlhat)

使用

打开sql文件后在文件头加上下面的信息:

--! product: mysql--! hostname: 127.0.0.1--! user: mysqluser--! password: mysqlpassword--! database: databasename

执行 sqlhat-connect 来创建 SQLi buffer

M-x sqlhat-connect
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn