Skip to content

dinhhuy258/vim-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-database

Introduction

Database management for Neovim.

  • Database explorer
  • Ability to execute queries
  • Edit/ copy/ delete data
  • ...

The supported databases at the moment:

  • SQLite
  • MySQL
  • PostgreSQL

Requirements

  • Neovim (vim is not supported)
  • Python 3.9
  • pynvim
  • pyyaml
  • sqlite3
  • psql
  • mysql

Install

Install pynvim

pip3 install pynvim

Install pyyaml

pip3 install pyyaml

Install Neovim plugin

Plug 'dinhhuy258/vim-database', {'branch': 'master', 'do': ':UpdateRemotePlugins'}

Install sqlite3 (Optional - skip if you don't use sqlite)

brew install sqlite

Install postgres client (Optional - skip if you don't use postgres)

brew install postgresql

Install msyql client (Optional - skip if you don't use mysql)

brew install mysql

Usage

  • VDToggleDatabase: Open or close database management
  • VDToggleQuery: Open or close query terminal
  • VimDatabaseListTablesFzf: List all tables in fzf

You can map these commands to another keys:

nnoremap <silent> <F3> :VDToggleDatabase<CR>
nnoremap <silent> <F4> :VDToggleQuery<CR>
nmap <silent> <Leader>fd :VimDatabaseListTablesFzf<CR>

If you see an error Not and editor command: VDToggleDatabase you need to run :UpdateRemotePlugins. If the error still occurs, run the following command

pip install --user --upgrade pynvim

then restart nvim and re-run :UpdateRemotePlugins and finally restart nvim, :VDToggleDatabase will exist

Key bindings

Check the default key binding here

Configuration

You can tweak the behavior of Database by setting a few variables in your vim setting file. For example:

let g:vim_database_rows_limit = 50
let g:vim_database_window_layout = "bottom"
...

g:vim_database_rows_limit

The maximum number of rows to display in table results.

Default: 50

g:vim_database_window_layout

Set the layout for database window.

Possible values:

  • left
  • right
  • above
  • below

Default: left

g:vim_database_window_size

Set size for database window.

Default: 100

Features

Navigate between connection, database, table mode:

  • <Leader> c: Go to connection mode
  • <Leader> d: Go to database mode
  • <Leader> t: Go to table mode

Connection mode

  • New connection (press c)
  • Delete connection (press dd)
  • Select connection (press s)
  • Modify connection (press m)

Database mode

  • Select database (press s)

Table mode

  • Filter table (press f)
  • Clear filter (press F)
  • Select table (press s)
  • Delete table (press dd)
  • Describe table (press .)

Data mode

  • Sort asc (press o)
  • Sort desc (press O)
  • Filter (press f)
  • Clear filter (press F)
  • Filter columns (press a)
  • Clear filter columns (press A)
  • Delete row (press dd)
  • Modify row at column (press m)
  • Copy row (press p)
  • Show create row query (press C)
  • Show update row query (press M)
  • Show update row query (press P)
  • Describe table (press .)
  • Next page (press right-arrow)
  • Previous page (press left-arrow)

Query mode

  • Execute the query (press r)