Minimal Multi database client for Neovim written in Go and Lua
MIT License
Minimal Multi database client for Neovim
Go v1.23.2
, unixodbc
.Linux
following open source philosophy.Database | Supported | Integrated by | NOTE |
---|---|---|---|
IBM DB2 | ✔️ | ODBC | Supported operations detailed here |
IBM Informix | ✔️ | ODBC | Supported operations detailed here |
MariaDB | ✔️ | Go | Supported operations detailed here |
MongoDB | ✔️ | Go | Supported operations detailed here |
MS-SQL | ✔️ | Go | Supported operations detailed here |
MySQL | ✔️ | Go | Supported operations detailed here |
Neo4j | ❌ | Go | Future release |
Oracle | ✔️ | Go | Supported operations detailed here |
PostgreSQL | ✔️ | Go | Supported operations detailed here |
Redis | ❌ | Go | Future release |
SQLite | ❌ | Go | Future release |
NOTE: The colorscheme nox from nvim-nyctophilia is used in this image.
Lazy
{
'javiorfo/nvim-dbeer',
dependencies = {
'javiorfo/nvim-popcorn',
'javiorfo/nvim-spinetta',
'nvim-telescope/telescope.nvim',
'nvim-lua/plenary.nvim',
},
lazy = true,
cmd = { "DBeerBuild" },
ft = { "sql", "javascript" }, -- javascript if MongoDB is used
build = function()
-- Update the backend in every plugin change
require'dbeer.core'.build()
end,
opts = {
-- This section is not required
-- Only if you want to change default configurations
-- Default keymaps
commands = {
-- Keymap in Normal mode to select DB with command :DBeerDB
select_db = '<CR>',
-- Keymap in Normal mode to expand and show connection data from DB with command :DBeerDB
expand_db = '<C-space>',
-- Keymap in Normal and Visual mode to execute a query
execute = '<C-t>',
-- Keymap in Normal mode to close all buffer results
close = '<C-c>',
},
-- Command :DBeerDB
view = {
-- Show the user name
show_user = true,
-- Show the user password
show_password = true,
},
-- Output buffer
output = {
-- Default dest folder where .dbeer files are created
-- The results will be erased after closing the buffer
-- If you want to keep the query results, change this to a personal folder
dest_folder = "/tmp",
-- Border style of the table result (1 to 6 to choose)
-- Single border, rounded corners, double border, etc
border_style = 1,
-- A "hi link column style" in header table results
header_style_link = "Type",
-- Height of the buffer table result
buffer_height = 20,
-- Override the results buffer
-- If false every query opens in a different buffer
override = false,
},
-- Configuration of databases (host, port, credentials, etc)
db = {
-- Default DB when open a buffer
default = 1,
-- connections are left empty by default
-- because these values are DB data connections set by the user
-- connections = {}
},
-- For errors and debug purposes if anything goes wrong
internal = {
-- Disabled by default
log_debug = false
}
}
}
setup
show above there is a section left out to be configured by the user (connections inside db table).Lazy
opts = {
db = {
-- Here when open a sql file (or js file in Mongo case) connection will set to 2nd element (postgres)
default = 2,
-- Required fields are:
-- name, engine and dbname
-- host and port will be the default in each engine if not set
-- user and password are optional
connections = {
{
name = "MongoDB some name",
engine = "mongo",
host = "123.4.1.8",
port = "27016",
dbname = "db_dummy",
user = "admin",
password = "admin",
},
{
name = "PostgreSQL example",
engine = "postgres",
dbname = "db_dummy",
user = "admin",
password = "admin",
},
{
name = "Oracle example",
engine = "oracle",
dbname = "db_dummy",
user = "admin",
password = "admin",
},
{
name = "MS-SQL 1",
engine = "mssql",
dbname = "db_dummy",
},
{
name = "MySQL something",
engine = "mysql", -- "mysql" also works for MariaDB
dbname = "db_dummy",
user = "admin",
password = "admin",
},
-- IBM Informix needs ODBC connection configured (check unix ODBC docs for this)
{
name = "Informix_ODBC", -- 'name' must match your DSN
engine = "informix",
dbname = "odbc" -- 'dbname' must be "odbc"
},
-- IBM DB2 needs ODBC connection configured (check unix ODBC docs for this)
{
name = "DB2_ODBC", -- 'name' must match your DSN
engine = "db2",
dbname = "odbc" -- 'dbname' must be "odbc"
},
}
}
}
Lazy
opts = {
db = dofile(os.getenv("HOME") .. "/path/to/connections.lua")
-- connections.lua will have something like
-- return {
-- default = 1,
-- connections = {
-- {...} -- here complete the connection data
-- }
-- }
}
db.mycollection.find({ "field1": "value1" }).sort({"info": -1})
// "db." is optional in nvim-dbeer. This will work too
mycollection.find({ "field1": "value1" }).sort({"info": -1})
NOTE: The colorscheme nox from nvim-nyctophilia is used in this image.
<C-t>
(could be modified by the user, see config above) if executed in NORMAL mode will take all the script (semicolon-separated) to process. But maybe it's best to execute it in VISUAL mode getting the same experience of a stardard DB IDE where a query can be selected and execute it in isolation instead of the entire script.NOTE: The colorscheme nox from nvim-nyctophilia is used in this image.
NOTE: The colorscheme nox from nvim-nyctophilia is used in this image.
Logs are saved generally in this path: /home/your_user/.local/state/nvim/dbeer.log
:dbeerLogs
NOTE: Only error logs are saved. If you want to enable debug phase, enable this on setup configuration:
require'dbeer'.setup {
internal = {
log_debug = true
}
}
NOTE: The colorscheme nox from nvim-nyctophilia is used in this image.