Skip to content

neovim plugin that lets you switch databases on demand or execute queries on different connections

License

Notifications You must be signed in to change notification settings

abenz1267/nvim-databasehelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nvim-databasehelper

Features

  • define various connections
  • discover Docker containers on demand
  • discover databases on connections/containers
  • change running database connection
    • restart LSP with proper connection
    • update vim-dadbod global connection string
  • execute statements (via vim-dadbod)
    • execute for different database/connection
  • caches Docker information for repeated usage
  • start/stop docker containers

Currently supported language servers

  • Postgres: sqls, sqlls is broken (see here)

Requires

Example Setup

WARNING: don't setup your LSP server manually, as you'll end up with multiple active clients.

require('nvim-databasehelper').setup(
    {
        lsp = {
            sqls = config, -- config you'd pass to lspconfig["sqls"].setup(). Omit the connections!
        },
        docker = {
            enabled = true,
            must_contain = { 'some' }, -- only show Docker containers that contain one of the given strings
            defaults = { -- when selecting a Docker container you'll be prompted for various parameters, you can define default values here
                postgresql = {
                    user = 'postgres',
                    password = 'somePassword',
                    initial_database = 'testdb',
                }
            }
        },
        dadbod = {
            enabled = true,
            var = 'dadbodstring', -- global Vim variable to use for dadbod ":DB g:<thisvariable> ..."
        },
        connections = {
            system = {
                initial_database = 'benchmark',
                driver = 'postgresql',
                host = '127.0.0.1',
                port = '5432',
                user = 'postgres',
                password = '',
            }
        },
        initial_window_height = 10,
    }
)

Commands

Command Function
SwitchDatabase switch database. Autocomplete or select window.
ExecuteOnDatabase execute buffer or visual selection on specific database.
ExecuteOnConnection execute buffer or visual selection on specific connection.
OpenDatabaseWindow opens a new buffer in the current window where you can write your query. Useful if you want LSP functionality.
StartContainer Starts the selected docker container
StopContainer Stops the selected docker container

About

neovim plugin that lets you switch databases on demand or execute queries on different connections

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages