Skip to content

Commit

Permalink
feat: databases tree view (#245)
Browse files Browse the repository at this point in the history
* feat(client): adapt the client to handler database-less connections

* feat(connection): add the change to make the database param non-mandatory

* feat(client): update the database implementations to be complaint with databaseQuerier interface

* feat(tui): refactor the tui to handler connection without the database

* fix(pkg): address ccoVeille comments Co-authored-by: ccoVeille <[email protected]>

* docs(readme): add instructions on how to use new tree view
  • Loading branch information
danvergara authored Nov 19, 2024
1 parent 459cc1b commit a0a6fdc
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 318 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Available Commands:
Flags:
--cfg-name string Database config name section
--config Get the connection data from a config file (default locations are: current directory, $HOME/.dblab.yaml or $XDG_CONFIG_HOME/.dblab.yaml)
--db string Database name
--db string Database name (optional)
--driver string Database driver
--encrypt string [strict|disable|false|true] data sent between client and server is encrypted or not
-h, --help help for dblab
Expand Down Expand Up @@ -264,8 +264,14 @@ Now, there's a menu to navigate between hidden views by just clicking on the des
<img src="screenshots/constraints-view.png" />
<img src="screenshots/indexes-view.png" />

As you may have noticed, navigation has already been added, so every time you query the content of a listed table, the result set is going to be paginated. This allows to the user dealing with large tables, optimizing resources.
Just hit the `BACK` and `NEXT` buttons to go back and forth.
~~As you may have noticed, navigation has already been added, so every time you query the content of a listed table, the result set is going to be paginated. This allows to the user dealing with large tables, optimizing resources.
Just hit the `BACK` and `NEXT` buttons to go back and forth.~~

The navigation buttons were removed since they are too slow to really navigate the content of a table. 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.

<img src="screenshots/tree-view.png" />

### Key Bindings
| Key | Description |
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func init() {
rootCmd.Flags().StringVarP(&port, "port", "", "", "Server port")
rootCmd.Flags().StringVarP(&user, "user", "", "", "Database user")
rootCmd.Flags().StringVarP(&pass, "pass", "", "", "Password for user")
rootCmd.Flags().StringVarP(&db, "db", "", "", "Database name")
rootCmd.Flags().StringVarP(&db, "db", "", "", "Database name (optional)")
rootCmd.Flags().StringVarP(&schema, "schema", "", "", "Database schema (postgres only)")
rootCmd.Flags().StringVarP(&ssl, "ssl", "", "", "SSL mode")
rootCmd.Flags().
Expand Down
Loading

0 comments on commit a0a6fdc

Please sign in to comment.