{"id":17639481,"url":"https://github.com/javiorfo/nvim-dbeer","last_synced_at":"2025-05-06T19:48:10.167Z","repository":{"id":239329369,"uuid":"797793738","full_name":"javiorfo/nvim-dbeer","owner":"javiorfo","description":"Minimal Multi database client for Neovim","archived":false,"fork":false,"pushed_at":"2025-03-04T22:59:51.000Z","size":171,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T02:22:01.328Z","etag":null,"topics":["database","go","golang","lua","neovim","neovim-plugin","nosql","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javiorfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-08T14:25:48.000Z","updated_at":"2025-03-05T17:49:13.000Z","dependencies_parsed_at":"2024-05-18T00:35:02.510Z","dependency_job_id":"1d58ba9f-4f87-431f-a0c3-bf9416b89cbe","html_url":"https://github.com/javiorfo/nvim-dbeer","commit_stats":{"total_commits":88,"total_committers":3,"mean_commits":"29.333333333333332","dds":0.2272727272727273,"last_synced_commit":"bcc0990cd58fc243060f6862f41fa473cced779d"},"previous_names":["javiorfo/nvim-coagula","javiorfo/nvim-dbking","javiorfo/nvim-dbeer","chaosystema/nvim-tabula","javiorfo/nvim-tabula"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fnvim-dbeer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fnvim-dbeer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fnvim-dbeer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fnvim-dbeer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javiorfo","download_url":"https://codeload.github.com/javiorfo/nvim-dbeer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252758305,"owners_count":21799818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","go","golang","lua","neovim","neovim-plugin","nosql","sql"],"created_at":"2024-10-23T05:02:15.106Z","updated_at":"2025-05-06T19:48:10.136Z","avatar_url":"https://github.com/javiorfo.png","language":"Go","funding_links":["https://www.paypal.com/donate/?hosted_button_id=FA7SGLSCT2H8G"],"categories":[],"sub_categories":[],"readme":"# nvim-dbeer\n*Minimal Multi database client for Neovim*\n\n## Caveats\n- These dependencies are required to be installed: `Go` (1.23), `unixodbc`. \n- For the sake of simplicity, **this plugin is STATELESS**. It does not use database sessions or keep states after Neovim is closed.\n- This plugin has been developed on and for `Linux` following open source philosophy.\n\n## Supported Databases\n#### Databases not marked will be supported in the future\n\n| Database | Supported | Connection | NOTE |\n| ------- | ------------- | ------ | ---- |\n| IBM DB2 | :heavy_check_mark: | ODBC | Supported operations detailed [here](#sql) |\n| IBM Informix | :heavy_check_mark: | ODBC | Supported operations detailed [here](#sql) |\n| MariaDB | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n| MongoDB | :heavy_check_mark: | Built-in | Supported operations detailed [here](#nosql) |\n| MS-SQL | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n| MySQL | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n| Neo4j | :x: | Built-in | Future release |\n| Oracle | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n| PostgreSQL | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n| Redis | :x: | Built-in | Future release |\n| SQLite | :heavy_check_mark: | Built-in | Supported operations detailed [here](#sql) |\n\n\n## Demo\n\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-demo.gif?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n**NOTE:** The colorscheme **nox** from [nvim-nyctophilia](https://github.com/javiorfo/nvim-nyctophilia) is used in this image.\n\n---\n\n## Table of Contents\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Supported Operations](#supported-operations)\n- [Usage](#usage)\n- [Commands](#commands)\n- [Tricks](#tricks)\n- [Logs](#logs)\n\n---\n\n## Installation\n`Lazy`\n```lua\n{ \n    'javiorfo/nvim-dbeer',\n    dependencies = {\n        'javiorfo/nvim-popcorn',\n        'javiorfo/nvim-spinetta',\n        'nvim-telescope/telescope.nvim',\n        'nvim-lua/plenary.nvim',\n    },\n    lazy = true,\n    cmd = { \"DBeerBuild\" },\n    ft = { \"sql\", \"javascript\" }, -- javascript if MongoDB is used\n    build = function()\n        -- Update the backend in every plugin change\n        require'dbeer.core'.build()\n    end,\n    opts = {\n        -- This section is not required\n        -- Only if you want to change default configurations\n      \n        -- Default keymaps\n        commands = {\n            -- Keymap in Normal mode to select DB with command :DBeerDB\n            select_db = '\u003cCR\u003e',\n        \n            -- Keymap in Normal mode to expand and show connection data from DB with command :DBeerDB\n            expand_db = '\u003cC-space\u003e',\n            \n            -- Keymap in Normal and Visual mode to execute a query\n            execute = '\u003cC-t\u003e',\n            \n            -- Keymap in Normal mode to close all buffer results\n            close = '\u003cC-c\u003e',\n        },\n\n        -- Command :DBeerDB\n        view = {\n            -- Show the user name\n            show_user = true,\n            \n            -- Show the user password\n            show_password = true,\n        },\n\n        -- Output buffer\n        output = {\n            -- Default dest folder where .dbeer files are created\n            -- The results will be erased after closing the buffer\n            -- If you want to keep the query results, change this to a personal folder\n            dest_folder = \"/tmp\",\n\n            -- Border style of the table result (1 to 6 to choose)\n            -- Single border, rounded corners, double border, etc\n            border_style = 1,\n\n            -- A \"hi link column style\" in header table results\n            header_style_link = \"Type\",\n\n            -- Height of the buffer table result\n            buffer_height = 20,\n\n            -- Override the results buffer\n            -- If false every query opens in a different buffer\n            override = false,\n        },\n\n        -- Configuration of databases (host, port, credentials, etc)\n        db = {\n            -- Default DB when open a buffer\n            default = 1,\n\n            -- connections are left empty by default\n            -- because these values are DB data connections set by the user\n            -- connections = {}\n        },\n\n        -- For errors and debug purposes if anything goes wrong\n        internal = {\n            -- Disabled by default\n            log_debug = false\n        }\n    }\n}\n```\n\n---\n\n## Configuration\n#### Configure DB connections and credentials\n- In the `setup` show above there is a section left out to be configured by the user (**connections** inside **db** table).\n- Here are some examples of different DB configurations\n- Engines possible values are: **mongo, postgres, oracle, mysql, sqlite, mssql, db2** and **informix**.\n\n`Lazy`\n```lua\nopts = {\n    db = {\n        -- Here when open a sql file (or js file in Mongo case) connection will set to 2nd element (postgres)\n        default = 2,\n        \n        -- Required fields are:\n        -- name, engine and dbname\n        -- host and port will be the default in each engine if not set\n        -- user and password are optional\n        connections = {\n            {\n                name = \"MongoDB some name\",\n                engine = \"mongo\",\n                host = \"123.4.1.8\",\n                port = \"27016\",\n                dbname = \"db_dummy\",\n                user = \"admin\",\n                password = \"admin\",\n            },\n            {\n                name = \"PostgreSQL example\",\n                engine = \"postgres\",\n                dbname = \"db_dummy\",\n                user = \"admin\",\n                password = \"admin\",\n            },\n            {\n                name = \"Oracle example\",\n                engine = \"oracle\",\n                dbname = \"db_dummy\",\n                user = \"admin\",\n                password = \"admin\",\n            },\n            {\n                name = \"MS-SQL example\",\n                engine = \"mssql\",\n                dbname = \"db_dummy\",\n            },\n            {\n                name = \"SQLite example\",\n                engine = \"sqlite\",\n                dbname = \"/path/to/db_dummy.db\", -- 'dbname' must contain the absolute path to the .db file or use \":memory:\"\n            },\n            {\n                name = \"MySQL example\",\n                engine = \"mysql\", -- \"mysql\" also works for MariaDB \n                dbname = \"db_dummy\",\n                user = \"admin\",\n                password = \"admin\",\n            },\n            -- IBM Informix needs ODBC connection configured (check unix ODBC docs for this)\n            {\n                name = \"Informix example\",\n                engine = \"informix\",\n                dbname = \"Informix_ODBC\", -- 'dbname' must match your DSN\n            },\n            -- IBM DB2 needs ODBC connection configured (check unix ODBC docs for this)\n            {\n                name = \"DB2 example\",\n                engine = \"db2\",\n                dbname = \"DB2_ODBC\", -- 'dbname' must match your DSN\n            },\n        }\n    }\n}\n```\n\n- I personally recommend having connections in the same folder where the sql or js scripts are stored. So you can check or set connections in the same folder you have database scripts.\n`Lazy`\n```lua\nopts = {\n    db = dofile(os.getenv(\"HOME\") .. \"/path/to/connections.lua\")\n\n    -- connections.lua will have something like\n    -- return {\n    --     default = 1,\n    --     connections = {\n    --         {...} -- here complete the connection data\n    --     }\n    -- }\n}\n```\n\n---\n\n## Supported Operations\n### Sql\n- [x] All select and subselect queries\n- [x] Commands insert, update, delete, create, modify, etc\n- [ ] Comments (queries with comments could not be processed)\n- Execution of multiple semicolon-separated queries\n    - [x] Commands insert, update, delete, create, modify, etc\n    - [ ] Select statements\n- [x] Command to list tables\n- [x] Command to get table info (fields, pk, fk, data type, etc)\n\n### NoSql\n- Operations\n    - [x] \"find\" with filters and subsequet \"sort\", \"skip\" or \"limit\"\n    - [x] \"countDocuments\"\n    - [x] \"findOne\" with filters\n    - [x] \"insertOne\"\n    - [x] \"deleteOne\"\n    - [x] \"updateOne\"\n    - [x] \"insertMany\"\n    - [x] \"deleteMany\"\n    - [x] \"updateMany\"\n    - [x] \"drop\" (drop collection)\n    - [ ] Indexes operations\n    - [ ] Replace operations\n    - [ ] Rename operations\n    - [ ] Aggregate operations\n- [ ] Comments (queries with comments could not be processed)\n- [ ] Execution of multiple semicolon-separated queries\n- [x] Command to list collections\n- [x] Command to get collection info (fields, data type, etc)\n\n##### Example\n```javascript\ndb.mycollection.find({ \"field1\": \"value1\" }).sort({\"info\": -1})\n\n// \"db.\" is optional in nvim-dbeer. This will work too\nmycollection.find({ \"field1\": \"value1\" }).sort({\"info\": -1})\n```\n\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-mongo.gif?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n**NOTE:** The colorscheme **nox** from [nvim-nyctophilia](https://github.com/javiorfo/nvim-nyctophilia) is used in this image.\n\n---\n\n## Usage\n- When a **sql file** or **js file** (in case of Mongo) is opened, Neovim will print what connection is set by default in nvim-dbeer. The connection to the database is done when the query is executed (open connection, execute statement, close connection), no session is set.\n- The keymap `\u003cC-t\u003e` (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.\n\n---\n\n## Commands\n### DBeerBuild\n- This is executed when this plugin receives and update, not necessary to be executed manually except if nvim-dbeer informs it.\n\n### DBeerLogs\n- Show the logs\n\n### DBeerDB\n- Command to change the DB connection to another one.\n- Show a expanded info of the DB (name, engine, host, port, credentials)\n\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-selectdb.gif?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n**NOTE:** The colorscheme **nox** from [nvim-nyctophilia](https://github.com/javiorfo/nvim-nyctophilia) is used in this image.\n\n### DBeerTables\n- This command uses telescope.nvim showing all the tables of the selected database\n- If you press enter after a table was selected, a popup show the \"selected table\" info\n\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-tableinfo.gif?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n**NOTE:** The colorscheme **nox** from [nvim-nyctophilia](https://github.com/javiorfo/nvim-nyctophilia) is used in this image.\n\n---\n\n## Tricks\nAs **nvim-dbeer** resets the default database connection everytime Neovim is close. There is a chance to set N scripts to X database everytime threy are opened. Using **Neovim autocmd** in **init.lua**:\n```lua\n-- Everytime test.sql, other.sql, update.sql are opened the default database is set to '2' \nvim.api.nvim_create_autocmd(\"BufReadPost\", {\n    pattern = { \"test.sql\", \"other.sql\", \"update.sql\" },\n    callback = function()\n        require 'dbeer'.default_db = 2\n    end,\n})\n```\n\n---\n\n## Logs\nLogs are saved generally in this path: **/home/your_user/.local/state/nvim/dbeer.log**\n\n- To check the logs execute the command `:dbeerLogs`\n\n**NOTE**: Only error logs are saved. If you want to enable debug phase, enable this on setup configuration:\n```lua\nrequire'dbeer'.setup {\n    internal = {\n       log_debug = true \n   }\n}\n```\n\n---\n\n## Screenshots\n#### Example executing the entire script (not select allowed) semicolon-separated\n- Note that in the fourth statement there is a duplicated primary key error reported\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-multi.png?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n#### Example example of border style 4 in table result\n\u003cimg src=\"https://github.com/javiorfo/img/blob/master/nvim-dbeer/dbeer-border.png?raw=true\" alt=\"nvim-dbeer\"/\u003e\n\n**NOTE:** The colorscheme **nox** from [nvim-nyctophilia](https://github.com/javiorfo/nvim-nyctophilia) is used in this image.\n\n---\n\n### Donate\n- **Bitcoin** [(QR)](https://raw.githubusercontent.com/javiorfo/img/master/crypto/bitcoin.png)  `1GqdJ63RDPE4eJKujHi166FAyigvHu5R7v`\n- [Paypal](https://www.paypal.com/donate/?hosted_button_id=FA7SGLSCT2H8G)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviorfo%2Fnvim-dbeer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaviorfo%2Fnvim-dbeer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviorfo%2Fnvim-dbeer/lists"}