pipe-mysql.vim


Ⅰ. 插件描述

MySQL client runner to query MySQL / Amazon Aurora / MariaDB database in Vim interactively (also remotely)

Ⅱ. 基本信息

创建日期:  2015-07-26
使用用户:  14
Github星:  43
插件作者:  Nikyle Nguyen

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'nlknguyen/pipe-mysql-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'nlknguyen/pipe-mysql-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'nlknguyen/pipe-mysql-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/nlknguyen/pipe-mysql.vim

Ⅳ. 文档说明

# pipe-mysql.vim
Easy-to-use MySQL client for Vim

Based on pipe.vim

Features

  • Work with MySQL database at local (with respect to Vim) or at remote machine (via SSH)
  • No need to have MySQL installed at local if you plan to execute MySQL statements at remote machine
  • Edit MySQL script locally, execute at remote machine, and get result back in Vim's Preview window at local
  • Execute a whole MySQL script file, a single line, or a block of MySQL statements
  • Set SSH remote and MySQL access on the fly; or use preset for frequently used login info
  • Each buffer has independent login info to database
  • Easily switch database on the fly
  • Include common queries to operate on the target where the cursor is at

Install

Using Vundle plugin manager:

Plugin 'NLKNguyen/pipe.vim' "required
Plugin 'NLKNguyen/pipe-mysql.vim'

Default Keymaps

The plugin comes with default keymaps for MySQL filetype. To turn off, add let g:pipemysql_no_mappings = 0 to your .vimrc file

Set Actions

ModeKeyActionFunction call
Normal<leader>srSet remote info (SSH)g:PipeMySQL_SetRemote()
Normal<leader>saSet MySQL access infog:PipeMySQL_SetAccess()
Normal<leader>sdSet database to useg:PipeMySQL_SetDatabase()
Normal<leader>seSet all fields emptyg:PipeMySQL_SetEmpty()
Normal<leader>spSelect preset info*g:PipeMySQL_SelectPreset()

* See Use Preset Login Info for how to store preset login info in .vimrc file

Run Actions

ModeKeyActionFunction call
Normal<leader>rfRun MySQL script fileg:PipeMySQL_RunFile()
Normal<leader>rsRun statement on the current lineg:PipeMySQL_RunLine()
Visual<leader>rsRun selected block of statementsg:PipeMySQL_RunBlock()
Normal<leader>rcRun custom statement (prompt)g:PipeMySQL_RunCustom()

Common Actions

ModeKeyActionFunction call
Normal<leader>dlList databasesg:PipeMySQL_DatabaseListing()
Normal<leader>dsSwitch databaseg:PipeMySQL_DatabaseSwitching()
Normal<leader>tlList tablesg:PipeMySQL_TableListing()
Normal<leader>tsSelect * from table at cursorg:PipeMySQL_TableSelectAll()
Normal<leader>tdDescribe table at cursorg:PipeMySQL_TableDescription()

Use Preset Login Info

In .vimrc you can store frequently used login info like the below snippet. The description value is what you see in the list of preset info in order to select.
All other fields are optional. They can be set on the fly using the Set Actions; therefore, you don't have to store sensitive information like password in .vimrc if you don't want to.

let g:pipemysql_login_info = [
                             \ {
                             \    'description' : 'my server 1',
                             \    'ssh_address' : 'root@server1',
                             \    'ssh_port' : '',
                             \    'mysql_hostname' : 'somehostname',
                             \    'mysql_username' : 'my_username',
                             \    'mysql_password' : 'my_password',
                             \    'mysql_database' : 'cs332h20'
                             \ },
                             \ {
                             \    'description' : 'my server 2',
                             \    'ssh' : 'root@server2',
                             \    'mysql_hostname' : 'somehostname',
                             \    'mysql_username' : 'my_username',
                             \ },
                             \ {
                             \    'description' : 'my local',
                             \    'mysql_hostname' : 'localhost',
                             \ }
                           \ ]

Suggestions/Wishes/Questions/Comments are welcome via Github issues

License MIT

Copyright (c) Nguyen Nguyen

添加新评论