Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nlknguyen/pipe-mysql.vim
MySQL client runner to query MySQL / Amazon Aurora / MariaDB database in Vim interactively (also remotely)
https://github.com/nlknguyen/pipe-mysql.vim
aurora client database mariadb mysql plugin vim
Last synced: 24 days ago
JSON representation
MySQL client runner to query MySQL / Amazon Aurora / MariaDB database in Vim interactively (also remotely)
- Host: GitHub
- URL: https://github.com/nlknguyen/pipe-mysql.vim
- Owner: NLKNguyen
- License: mit
- Created: 2015-07-26T07:21:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T08:11:21.000Z (over 1 year ago)
- Last Synced: 2024-04-14T01:00:02.403Z (7 months ago)
- Topics: aurora, client, database, mariadb, mysql, plugin, vim
- Language: Vim Script
- Homepage: https://github.com/NLKNguyen/pipe-mysql.vim
- Size: 25.4 KB
- Stars: 54
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pipe-mysql.vim
Easy-to-use MySQL client for Vim
Based on [pipe.vim](https://github.com/NLKNguyen/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> by default, it works for filetype 'mysql'. so if you want to use othertype (ex. sql), set in your .vimrc like `au BufRead,BufNewFile *.sql set filetype=mysql`
# Install
Using [Vundle](https://github.com/VundleVim/Vundle.vim) plugin manager:
```VimL
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
| Mode | Key | Action | Function call |
| --- | --- | --- | --- |
| Normal | `sr` | Set remote info (SSH) | g:PipeMySQL_SetRemote() |
| Normal | `sa` | Set MySQL access info | g:PipeMySQL_SetAccess() |
| Normal | `sd` | Set database to use | g:PipeMySQL_SetDatabase() |
| Normal | `se` | Set all fields empty | g:PipeMySQL_SetEmpty() |
| Normal | `sp` | Select preset info\* | g:PipeMySQL_SelectPreset() |\* See **Use Preset Login Info** for how to store preset login info in .vimrc file
## Run Actions
| Mode | Key | Action | Function call |
| --- | --- | --- | --- |
| Normal | `rf` | Run MySQL script file | g:PipeMySQL_RunFile() |
| Normal | `rs` | Run statement on the current line (table view) | g:PipeMySQL_RunLine('table') |
| Visual | `rs` | Run selected block of statements (table view) | g:PipeMySQL_RunBlock('table') |
| Normal | `rS` | Run statement on the current line (batch view) | g:PipeMySQL_RunLine('batch') |
| Visual | `rS` | Run selected block of statements (batch view) | g:PipeMySQL_RunBlock('batch') |
| Normal | `rc` | Run custom statement (prompt) | g:PipeMySQL_RunCustom() |## Common Actions
| Mode | Key | Action | Function call |
| --- | --- | --- | --- |
| Normal | `dl` | List databases | g:PipeMySQL_DatabaseListing() |
| Normal | `ds` | Switch database | g:PipeMySQL_DatabaseSwitching() |
| Normal | `tl` | List tables | g:PipeMySQL_TableListing() |
| Normal | `ts` | Select \* from table at cursor | g:PipeMySQL_TableSelectAll() |
| Normal | `td` | Describe table at cursor | g:PipeMySQL_TableDescription() |
| Normal | `tD` | Show `create` SQL definition of table at cursor | g:PipeMySQL_TableDefinition() |## 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.
if in your preset mysql_password is not specified, then follow mysql-clients setting for that.
(for example, find it from `.my.cnf`).
and you can also use defaults file for mysql access configuration.
in below example, using .test.my.cnf file for 4th preset.```VimL
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',
\ },
\ {
\ 'decription' : 'using defaults file',
\ 'mysql_defaults_file' : '$HOME/.test.my.cnf'
\ }
\ ]
```example for .test.my.cnf
this configuration is can be used when your enviroments are diverse, and
maintain connection with seperated file as traditional in mysql configuration.```ini
[mysql]
host=my-awesome-prod-server
user=my-user
password=my_password```
## Use Variables
In `.vimrc` you can set mysql options by using variables.```VimL
let g:pipemysql_option = '-vvv'
let g:pipemysql_pager = 'grcat ~/.grcat'
```the variables
| variable | description |
| - | - |
| pipemysql_option | set mysql custom option. for example (-vvv, -show-warnings). some options actually does not affect behavior cause the client was disconnected after executes. check: [mysql-doc](https://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html) |
| pipemysql_pager | give pager option to mysql client. check: [mysql-doc](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-using-pager.html) |# 👋 Author
👤 **Nikyle Nguyen**
- Website:
- Twitter: [@NLKNguyen](https://twitter.com/NLKNguyen)
- Github: [@NLKNguyen](https://github.com/NLKNguyen)
- LinkedIn: [@NLKNguyen](https://linkedin.com/in/NLKNguyen)# 🤝 Contributing
Give a ⭐️ if this project helped you working with MySQL in Vim seamlessly!
Contributions, issues and feature requests are welcome! Feel free to check [issues page](https://github.com/NLKNguyen/pipe-mysql.vim/issues).
## 🙇 Your support is very much appreciated
I create open-source projects on GitHub and continue to develop/maintain as they are helping others. You can integrate and use these projects in your applications for free! You are free to modify and redistribute anyway you like, even in commercial products.
I try to respond to users' feedback and feature requests as much as possible. Obviously, this takes a lot of time and efforts (speaking of mental context-switching between different projects and daily work). Therefore, if these projects help you in your work, and you want to encourage me to continue create, here are a few ways you can support me:
- 💬 Following my blog and social profiles listed above to help me connect with your network
- ⭐️ Starring this project and sharing with others as more users come, more great ideas arrive!
- ☘️ Donating any amount is a great way to help me work on the projects more regularly!Thanks to all contributors who make pipe-mysql.vim great! ❤️
# 📝 License
Copyright © 2015 - 2020 [Nikyle Nguyen](https://github.com/NLKNguyen)
The project is [MIT License](https://github.com/NLKNguyen/S-Expression.JS/blob/master/LICENSE)