Skip to content

Editor Features ​

DevDb connects your code to your database. These features work when DevDb shows a database in the panel.

Go to table ​

Press Cmd+K Cmd+G (macOS) or Ctrl+K Ctrl+G (Windows, Linux). Or run Go to Table from the Command Palette.

Type part of the table name, then press Enter. DevDb opens the table.

Context menu ​

Right-click in the editor, then open the DevDb submenu.

ItemLanguagesDescription
Open table at cursorAllOpens the table for the word at the cursor
Generate Laravel FactoryPHPGenerates a factory for the model at the cursor
Explain queryPHPExplains the selected query

Open table at cursor ​

This works in all languages and frameworks. DevDb converts the word at the cursor to snake_case, then looks for a table with that name. If there is no table, it tries the plural form.

Word at cursorTables that DevDb tries
Useruser, then users
OrderItemorder_item, then order_items
blog_postsblog_posts

Laravel ​

CodeLens for Eloquent models ​

In a Laravel Eloquent model file, DevDb shows CodeLens actions above the class:

  • View table: opens the table of the model.
  • Generate Factory: generates a factory for the model.

If DevDb is not connected, the CodeLens asks you to connect first.

Factory generator ​

DevDb creates a model factory that uses real data from your table.

  1. Open a model, then click Generate Factory. Or right-click the model name and select DevDb > Generate Laravel Factory.
  2. DevDb runs php artisan make:factory, then fills in the definition() method with values from real rows in the table.
  3. DevDb opens the new file in database/factories/.

If the factory exists, DevDb asks you to select Open Existing or Overwrite.

Requirements:

Query explainer ​

The query explainer uses MySQL Visual Explain to show the execution plan of a query.

  1. In a Laravel PHP file, select the code that runs one query. For example, an Eloquent query or a DB facade call.
  2. Click the Explain query CodeLens, or right-click and select DevDb > Explain query.
  3. Select Open in Browser or Copy URL.

DevDb supports one query at a time. It works with MySQL and MariaDB.

WARNING

To get the SQL, DevDb runs the selected code in your Laravel app. Select only code that reads data.

DevDb sends the query, its bindings, the MySQL version and the execution plan to api.mysqlexplain.com. Do not use the explainer on queries that contain sensitive data.

To hide the Explain query CodeLens on selected text, set Devdb.enableCodeLensForTextSelection to false.

Export table data ​

Export the rows of a table as JSON or as SQL INSERT statements.

  1. Open a table.
  2. Click Export.
  3. Select the destination (Clipboard or File) and the format (SQL or JSON).
    • Clipboard: DevDb copies the data.
    • File: DevDb asks where to save the .json or .sql file.

DevDb exports the rows of the current page. To export more rows, increase the page size or apply a filter first.

Multi-root workspaces ​

DevDb does not fully support multi-root workspaces yet. Track the progress in issue #68. Use Devdb.customBasePath to select the folder.

DevDb - Zero-config database client for VS Code