diff --git a/assets/tutorials/images/constraints-result.png b/assets/tutorials/images/constraints-result.png index 4191262..0d24c5b 100644 Binary files a/assets/tutorials/images/constraints-result.png and b/assets/tutorials/images/constraints-result.png differ diff --git a/assets/tutorials/images/full-ui.png b/assets/tutorials/images/full-ui.png index d7a396f..5bcef8b 100644 Binary files a/assets/tutorials/images/full-ui.png and b/assets/tutorials/images/full-ui.png differ diff --git a/assets/tutorials/images/indexes-result.png b/assets/tutorials/images/indexes-result.png index 5e2657f..05a8fea 100644 Binary files a/assets/tutorials/images/indexes-result.png and b/assets/tutorials/images/indexes-result.png differ diff --git a/assets/tutorials/images/left-menu.png b/assets/tutorials/images/left-menu.png index d9bf201..f406d41 100644 Binary files a/assets/tutorials/images/left-menu.png and b/assets/tutorials/images/left-menu.png differ diff --git a/assets/tutorials/images/rows-result.png b/assets/tutorials/images/rows-result.png index 52847e5..b33ba3a 100644 Binary files a/assets/tutorials/images/rows-result.png and b/assets/tutorials/images/rows-result.png differ diff --git a/assets/tutorials/images/structure-result.png b/assets/tutorials/images/structure-result.png index 4c854fb..c8d18d5 100644 Binary files a/assets/tutorials/images/structure-result.png and b/assets/tutorials/images/structure-result.png differ diff --git a/assets/tutorials/images/tab-menu.png b/assets/tutorials/images/tab-menu.png deleted file mode 100644 index 7fb167f..0000000 Binary files a/assets/tutorials/images/tab-menu.png and /dev/null differ diff --git a/docs/index.md b/docs/index.md index 1e063e3..73de5b4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,13 +16,14 @@ Cross-platform, zero dependencies, terminal based UI application for your Data B ## Overview -**dblab** is a fast and lightweight interactive terminal based UI application for PostgreSQL, MySQL and SQLite3, written in Go and works on OSX, Linux and Windows machines. - -The main idea behind using Go for backend development is to utilize the ability of the compiler to produce zero-dependency binaries for multiple platforms. - -dblab was created as an attempt to build a very simple and portable application to interact with local or remote PostgreSQL/MySQL/SQLite3 databases. +dblab is a fast and lightweight interactive terminal based UI application for PostgreSQL, MySQL and SQLite3, +written in Go and works on OSX, Linux and Windows machines. Main idea behind using Go for backend development +is to utilize ability of the compiler to produce zero-dependency binaries for +multiple platforms. dblab was created as an attempt to build very simple and portable +application to work with local or remote PostgreSQL/MySQL/SQLite3/Oracle/SQL Server databases. -The key features are: + +## Features * Cross-platform support OSX/Linux/Windows 32/64-bit * Simple installation (distributed as a single binary) diff --git a/docs/quickstart.md b/docs/quickstart.md index f9f4ff9..4e2932f 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -2,7 +2,7 @@ You can start the app without passing flags or parameters, so then an interactive command prompt will ask for the connection details. -![Alt Text](https://raw.githubusercontent.com/danvergara/dblab/main/screenshots/dblab-default-form.gif){ width="500" : .center } +![Alt Text](https://raw.githubusercontent.com/danvergara/dblab/main/screenshots/dblab-demo.gif){ width="500" : .center } Otherwise, you can explicitly include the connection details using multiple parameters: diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md index b62f872..a389018 100644 --- a/docs/tutorials/index.md +++ b/docs/tutorials/index.md @@ -35,5 +35,3 @@ If everything went well you should see the UI ![dblab](https://raw.githubusercontent.com/danvergara/dblab/main/assets/tutorials/images/full-ui.png){ width="700" : .center } For further knowledge on the navigation of the UI you can check this [first steps in navigation](https://dblab.danvergara.com/tutorials/navigation/) - - diff --git a/docs/tutorials/navigation.md b/docs/tutorials/navigation.md index 19f2815..1fd2e6d 100644 --- a/docs/tutorials/navigation.md +++ b/docs/tutorials/navigation.md @@ -1,10 +1,6 @@ One of the main features of dblab is to be a simple but very useful UI to interact with your database. ![dblab](https://raw.githubusercontent.com/danvergara/dblab/main/assets/tutorials/images/full-ui.png){ width="700" : .center } -In the top right you can find a tab menu were you can navigate through the different panels using: - -![dblab](https://raw.githubusercontent.com/danvergara/dblab/main/assets/tutorials/images/tab-menu.png){ width="500" : .center } - - Ctrl+I to move from Rows to Indexes and backwards. - Ctrl+F to move from Rows to Constraints and backwards. - Ctrl+S to move from Rows to Structure and backwards. diff --git a/docs/usage.md b/docs/usage.md index 2c9ee24..14f8772 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -21,25 +21,52 @@ $ dblab [command] ### Flags -| Flag | Type | Description | -|:----------------:|:-----------:|:----------------------------------------------------------------------------------------------------------------------------------| -| `--cfg-name` | `string` | Database config name section | -| `--config` | | Get the connection data from a config file (default is $HOME/.dblab.yaml or the current directory) | -| `--db` | `string` | Database name | -| `--driver` | `string` | Database driver | -| `-h, --help` | | help for dblab | -| `--host` | `string` | Server host name or IP | -| `--limit` | `int` | Size of the result set from the table content query (should be greater than zero, otherwise the app will error out) (default 100) | -| `--pass` | `string` | Password for user | -| `--port` | `string` | Server port | -| `--schema` | `string` | Database schema (postgres only) | -| `--socket` | `string ` | Path to a Unix socket file | -| `--ssl` | `string` | SSL mode | -| `-u, --url` | `string` | Database connection string | -| `--user` | `string` | Database user | - -Use `dblab [command] --help` for more information about a command. - +``` +dblab is a terminal UI based interactive database client for Postgres, MySQL and SQLite3. + +Usage: + dblab [flags] + dblab [command] + +Available Commands: + help Help about any command + version The version of the project + +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 (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 + --host string Server host name or IP + --limit uint Size of the result set from the table content query (should be greater than zero, otherwise the app will error out) (default 100) + --pass string Password for user + --port string Server port + --schema string Database schema (postgres only) + --socket string Path to a Unix socket file + --ssh-host string SSH Server Hostname/IP + --ssh-key string File with private key for SSH authentication + --ssh-key-pass string Supports connections with protected private keys with passphrase + --ssh-pass string SSH Password (Empty string for no password) + --ssh-port string SSH Port + --ssh-user string SSH User + --ssl string SSL mode + --ssl-verify string [enable|disable] or [true|false] enable ssl verify for the server + --sslcert string This parameter specifies the file name of the client SSL certificate, replacing the default ~/.postgresql/postgresql.crt + --sslkey string This parameter specifies the location for the secret key used for the client certificate. It can either specify a file name that will be used instead of the default ~/.postgresql/postgresql.key, or it can specify a key obtained from an external “engine” + --sslpassword string This parameter specifies the password for the secret key specified in sslkey + --sslrootcert string This parameter specifies the name of a file containing SSL certificate authority (CA) certificate(s) The default is ~/.postgresql/root.crt + --timeout string in seconds (default is 0 for no timeout), set to 0 for no timeout. Recommended to set to 0 and use context to manage query and connection timeouts + --trace-file string File name for trace log + --trust-server-certificate string [false|true] server certificate is checked or not + -u, --url string Database connection string + --user string Database user + -v, --version version for dblab + --wallet string Path for auto-login oracle wallet + +Use "dblab [command] --help" for more information about a command. +``` ## Navigation @@ -89,7 +116,7 @@ Key | Description You can start the app without passing flags or parameters, so then an interactive command prompt will ask for the connection details. -![Alt Text](https://raw.githubusercontent.com/danvergara/dblab/main/screenshots/dblab-default-form.gif){ width="500" : .center } +![Alt Text](https://raw.githubusercontent.com/danvergara/dblab/main/screenshots/dblab-demo.gif){ width="500" : .center } Otherwise, you can explicitly include the connection details using multiple parameters: @@ -99,6 +126,12 @@ dblab --host localhost --user myuser --db users --pass password --ssl disable -- ```{ .sh .copy } dblab --db path/to/file.sqlite3 --driver sqlite ``` +```{ .sh .copy } +dblab --host localhost --user system --db FREEPDB1 --pass password --port 1521 --driver oracle --limit 50 +``` +```{ .sh .copy } +dblab --host localhost --user SA --db msdb --pass '5@klkbN#ABC' --port 1433 --driver sqlserver --limit 50 +``` Connection URL scheme is also supported: @@ -111,6 +144,12 @@ dblab --url mysql://user:password@tcp(host:port)/db ```{ .sh .copy } dblab --url file:test.db?cache=shared&mode=memory ``` +```{ .sh .copy } +dblab --url 'oracle://user:password@localhost:1521/db' +``` +```{ .sh .copy } +dblab --url 'sqlserver://SA:myStrong(!)Password@localhost:1433?database=tempdb&encrypt=true&trustservercertificate=false&connection+timeout=30' +``` if you're using PostgreSQL, you have the option to define the schema you want to work with, the default value is `public`. @@ -130,12 +169,72 @@ dblab --url "mysql://user:password@unix(/path/to/socket/mysql.sock)/dbname?chars dblab --socket /path/to/socket/mysql.sock --user user --db dbname --pass password --ssl disable --port 5432 --driver mysql --limit 50 ``` +Postgres connection through Unix sockets: + +```sh +$ dblab --url "postgres://user:password@/dbname?host=/path/to/socket" +$ dblab --socket /path/to/socket --user user --db dbname --pass password --ssl disable --port 5432 --driver postgres --limit 50 +``` + Now, it is possible to ensure SSL connections with `PostgreSQL` databases. SSL related parameters has been added, such as `--sslcert`, `--sslkey`, `--sslpassword`, `--sslrootcert`. More information on how to use such connection flags can be found [here](https://www.postgresql.org/docs/current/libpq-connect.html). ```{ .sh .copy } dblab --host db-postgresql-nyc3-56456-do-user-foo-0.fake.db.ondigitalocean.com --user myuser --db users --pass password --schema myschema --port 5432 --driver postgres --limit 50 --ssl require --sslrootcert ~/Downloads/foo.crt ``` +### SSH Tunnel + +Now, it's possible to connect to Postgres or MySQL (more to come later) databases on a server via SSH using password or a ssh key files. + +To do so, 6 new flags has been added to the dblab command: + +| Flag | Description | +|----------------------|-------------------------------------------------------------------| +| --ssh-host | SSH Server Hostname/IP | +| --ssh-port | SSH Port | +| --ssh-user | SSH User | +| --ssh-pass | SSH Password (Empty string for no password) | +| --ssh-key | File with private key for SSH authentication | +| --ssh-key-pass | Passphrase for protected private key files | + +#### Examples + +Postgres connection via ssh tunnel using password: + +```{ .sh .copy } +dblab --host localhost --user postgres --pass password --schema public --ssl disable --port 5432 --driver postgres --limit 50 --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-pass root +``` + +Postgres connection via ssh tunnel using ssh private key file: + +```{ .sh .copy } +dblab --host localhost --user postgres --pass password --schema public --ssl disable --port 5432 --driver postgres --limit 50 --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-key my_ssh_key --ssh-key-pass password +``` + +Postgres connection using the url parameter via ssh tunnel using password: + +```{ .sh .copy } +dblab --url postgres://postgres:password@localhost:5432/users?sslmode=disable --schema public --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-pass root +``` + +MySQL connection via ssh tunnel using password: + +```{ .sh .copy } +dblab --host localhost --user myuser --db mydb --pass 5@klkbN#ABC --ssl enable --port 3306 --driver mysql --limit 50 --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-pass root +``` + +MySQL connection via ssh tunnel using ssh private key file: + +```{ .sh .copy } +dblab --host localhost --user postgres --pass password --ssl enable --port 3306 --driver mysql --limit 50 --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-key my_ssh_key --ssh-key-pass passphrase +``` + +MySQL connection using the url parameter via ssh tunnel using password: + +```{ .sh .copy } +dblab --url "mysql://myuser:5@klkbN#ABC@mysql+tcp(localhost:3306)/mydb" --driver mysql --ssh-host example.com --ssh-port 22 --ssh-user root --ssh-pass root +``` + ### Configuration Entering the parameters and flags every time you want to use it is tedious, @@ -186,6 +285,35 @@ database: driver: "postgres" ssl: "require" sslrootcert: "~/.postgresql/root.crt." + - name: "oracle" + host: "localhost" + port: 1521 + db: "FREEPDB1 " + password: "password" + user: "system" + driver: "oracle" + ssl: "enable" + wallet: "path/to/wallet" + ssl-verify: true + - name: "sqlserver" + driver: "sqlserver" + host: "localhost" + port: 1433 + db: "msdb" + password: "5@klkbN#ABC" + user: "SA" + - name: "ssh-tunnel" + host: "localhost" + port: 5432 + db: "users" + password: "password" + user: "postgres" + schema: "public" + driver: "postgres" + ssh-host: "example.com" + ssh-port: 22 + ssh-user: "ssh-user" + ssh-pass: "password" # should be greater than 0, otherwise the app will error out limit: 50 ``` @@ -199,4 +327,4 @@ database: driver: "sqlite" ``` -Only the `host` and `ssl` fields are optionals. `127.0.0.1` and `disable`, respectively. +only the `host` and `ssl` fields are optionals. `127.0.0.1` and `disable`, respectively.