{ "uuid": [ { "value": "b475d325-7c60-4115-b465-f1d691ab75b0" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:50+00:00" } ], "revision_uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "revision_log": [], "status": [ { "value": true } ], "uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "title": [ { "value": "Managing databases with Neovim and Docker\n" } ], "created": [ { "value": "2022-12-10T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:50+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2022\/12\/10\/managing-databases-with-neovim-and-docker", "langcode": "en" } ], "body": [ { "value": "\n

If you work on software projects that use a database, you need a convenient way to connect, inspect, and query them.<\/p>\n\n

Some IDEs like PhpStorm have an integrated database client, which I've recently added to my Neovim setup and working with Docker and Docker Compose.<\/p>\n\n

Configuring Docker Compose<\/h2>\n\n

A local port needs to be exposed from the database container that Neovim can connect to.<\/p>\n\n

I usually do this with a docker-compose.override.yaml<\/code> file:<\/p>\n\n

services:\n  database:\n    ports:\n      - 3307:3306\n<\/code><\/pre>\n\n

Docker Compose recognises this by default, extends the normal docker-compose.yaml<\/code> file and adds a port forwarding to the database<\/code> service.<\/p>\n\n

Configuring Neovim<\/h2>\n\n

The two plugins I'm using are tpope\/vim-dadbod and kristijanhusak\/vim-dadbod-ui, and should work with Vim and Neovim. Thanks to both of these project maintainers.<\/p>\n\n

Once installed, run :DBUIAddconnection<\/code> to add a database connection.<\/p>\n\n

Here is an example connection string:<\/p>\n\n

mysql:\/\/drupal:drupal@localhost:3307\/drupal?protocol=tcp\n<\/code><\/pre>\n\n

Using the local port mapping, this connects to a MySQL database within the database<\/code> service.<\/p>\n\n

Then run :DBUI<\/code> to toggle the UI and see a list of databases in the left-hand sidebar.<\/p>\n\n

You can enter <leader>R<\/code> to refresh databases or r<\/code> to rename or update connection details for a specific database.<\/p>\n\n

Once connected, you can enter and save queries, using table and column name completion, which are executed every time the query is saved.<\/p>\n\n

I like not needing to switch contexts and leave my editor in order to query a database, and feel a lot more productive being able to write, execute and save queries within this UI.<\/p>\n\n

If you're a Vim or Neovim user, I'd suggest trying this setup and seeing if it works for you.<\/p>\n\n ", "format": "full_html", "processed": "\n

If you work on software projects that use a database, you need a convenient way to connect, inspect, and query them.<\/p>\n\n

Some IDEs like PhpStorm have an integrated database client, which I've recently added to my Neovim setup and working with Docker and Docker Compose.<\/p>\n\n

Configuring Docker Compose<\/h2>\n\n

A local port needs to be exposed from the database container that Neovim can connect to.<\/p>\n\n

I usually do this with a docker-compose.override.yaml<\/code> file:<\/p>\n\n

services:\n  database:\n    ports:\n      - 3307:3306\n<\/code><\/pre>\n\n

Docker Compose recognises this by default, extends the normal docker-compose.yaml<\/code> file and adds a port forwarding to the database<\/code> service.<\/p>\n\n

Configuring Neovim<\/h2>\n\n

The two plugins I'm using are tpope\/vim-dadbod and kristijanhusak\/vim-dadbod-ui, and should work with Vim and Neovim. Thanks to both of these project maintainers.<\/p>\n\n

Once installed, run :DBUIAddconnection<\/code> to add a database connection.<\/p>\n\n

Here is an example connection string:<\/p>\n\n

mysql:\/\/drupal:drupal@localhost:3307\/drupal?protocol=tcp\n<\/code><\/pre>\n\n

Using the local port mapping, this connects to a MySQL database within the database<\/code> service.<\/p>\n\n

Then run :DBUI<\/code> to toggle the UI and see a list of databases in the left-hand sidebar.<\/p>\n\n

You can enter <leader>R<\/code> to refresh databases or r<\/code> to rename or update connection details for a specific database.<\/p>\n\n

Once connected, you can enter and save queries, using table and column name completion, which are executed every time the query is saved.<\/p>\n\n

I like not needing to switch contexts and leave my editor in order to query a database, and feel a lot more productive being able to write, execute and save queries within this UI.<\/p>\n\n

If you're a Vim or Neovim user, I'd suggest trying this setup and seeing if it works for you.<\/p>\n\n ", "summary": null } ] }