Skip to content

Navigation

One of the main features of dblab is its simple but very useful UI for interacting with your database.
dblab

Query editor

The query editor uses normal and insert modes (similar to Vim). When you focus the query editor, it starts in normal mode. Press i to enter insert mode and type or edit SQL; press Escape to return to normal mode (the cursor moves one character to the left, as in Vim). In insert mode, use the arrow keys to move the cursor; in normal mode, use h, j, k, and l instead (configurable in .dblab.yaml with --keybindings or -k; see Key bindings configuration). In normal mode, dd deletes the current line, yy yanks the current line into an internal register, p pastes that line after the current line, and x deletes the character under the cursor. 0 and $ move to the beginning or end of the current line in the query buffer. Press ctrl+e to execute the query (this uses the keybindings.editor.execute-query binding); whitespace-only queries are ignored.

Otherwise, you might be located at the tables panel, where you can navigate using the arrows Up and Down (or the keys k and j respectively). If you want to see the rows of a table, press Enter. To see the schema of a table, locate yourself on the tables panel and press tab to switch to the columns panel, then use shift+tab to switch back.

Now, there's a menu to navigate between hidden views by just clicking on the desired options:

  • Data: Will show the result of the executed query. Press ctrl+e to execute the query. dblab
  • Columns: Will show the schema of the table selected
    dblab
  • Indexes: Will show the indexes of the table selected
    dblab
  • Constraints: Will show the constraints of the table selected
    dblab

In order to be able to see the information for Columns, Indexes, or Constraints, first you need to select a table from the left menu.

To navigate there you can use:

  • tab: If the result set panel is focused, press tab to navigate to the next metadata tab.
  • shift+tab: If the result set panel is focused, press shift+tab to navigate to the previous metadata tab.

Once the correct name is highlighted in the left menu, press Enter to select the table. Now you can navigate to the different panels to see the related information.

dblab

The navigation buttons were removed since they are too slow to navigate the content of a table effectively. The user is better off typing a SELECT statement with proper OFFSET and LIMIT.

The --db flag is now optional (except for Oracle), meaning that the user will be able to see the list of databases they have access to. The regular list of tables will be replaced with a tree structure showing a list of databases and their respective list of tables, branching off each database. Due to the nature of the vast majority of DBMSs that don't allow cross-database queries, dblab has to open an independent connection for each database. The side effect of this decision is that the user has to press Enter on the specific database of interest. An indicator showing the current active database will appear at the bottom-right of the screen. To change the focus, just hit enter on another database. Once a database is selected, the usual behavior of inspecting tables remains the same.

dblab

When navigating query result sets, the cell will be highlighted so the user can see which table cell is selected. This is important because you can press the Enter key on a cell of interest to copy its content.

Key Bindings

Key Description
ctrl+e If the query editor is focused, execute the query (also works in insert and normal mode)
i If the query editor is focused in normal mode, enter insert mode
Escape If the query editor is focused in insert mode, return to normal mode
dd If the query editor is focused in normal mode, delete the current line
yy If the query editor is focused in normal mode, yank the current line
p If the query editor is focused in normal mode, paste the yanked or deleted line after the current line
x If the query editor is focused in normal mode, delete the character under the cursor
Enter If the tables panel is focused, list all rows as a result set on the rows panel and display the structure of the table on the structure panel
tab If the result set panel is focused, press tab to navigate to the next metadata tab
shift+tab If the result set panel is focused, press shift+tab to navigate to the previous metadata tab
Ctrl+H Toggle to the panel on the left
Ctrl+J Toggle to the panel below
Ctrl+K Toggle to the panel above
Ctrl+L Toggle to the panel on the right
Arrow Up If the query editor is focused in insert mode, move the cursor up. If the results panel is focused, navigate the table upward (all tabs on the results panel).
k If the query editor is focused in normal mode, move the cursor up. If the results panel is focused, navigate the table upward (all tabs on the results panel).
Arrow Down If the query editor is focused in insert mode, move the cursor down. If the results panel is focused, navigate the table downward (all tabs on the results panel).
j If the query editor is focused in normal mode, move the cursor down. If the results panel is focused, navigate the table downward (all tabs on the results panel).
Arrow Right If the query editor is focused in insert mode, move the cursor right. If the results panel is focused, navigate the table to the right (all tabs on the results panel).
l If the query editor is focused in normal mode, move the cursor right. If the results panel is focused, navigate the table to the right (all tabs on the results panel).
Arrow Left If the query editor is focused in insert mode, move the cursor left. If the results panel is focused, navigate the table to the left (all tabs on the results panel).
h If the query editor is focused in normal mode, move the cursor left. If the results panel is focused, navigate the table to the left (all tabs on the results panel).
g If the results panel is focused, move to the top of the dataset (all tabs on the results panel).
G If the results panel is focused, move to the bottom of the dataset (all tabs on the results panel).
0 If the query editor is focused in normal mode, move to the start of the current line. If the results panel is focused, move to the left edge of the row (all tabs on the results panel).
$ If the query editor is focused in normal mode, move to the end of the current line. If the results panel is focused, move to the right edge of the row (all tabs on the results panel).
Ctrl+c Quit