Important
Before using these commands you need to add your database configuration in config (~/.hckrcfg file), please refer Configuring your databases
hckr db¶
Database commands
hckr db [OPTIONS] COMMAND [ARGS]...
query¶
This command executes a SQL query on your configured database and show you result in a table format ( in
SELECT/SHOW/DESC queries )
Example Usage:
Running a simple query on your configured database
$ hckr db query "select 1 as key, 'one' as value" -c testdb_sqlite
key |
value |
|---|---|
1 |
one |
Note
here, we have configured Sqlite database with in a config ‘testdb_sqlite’
using Configuring your databases
Additionally, we can also limit number of records and columns returned by the query using
-nr/--num-rowsand-nc/--num-colsoptions
$ hckr db query "select 1 as key, 'one' as value" -c testdb_sqlite -nr 1 -nc 1
Command Reference:
hckr db query [OPTIONS] QUERY
Options
- -f, --config-path <config_path>¶
Config file path, default:
~/.hckrcfg
- -c, --config <config>¶
Config instance, default:
DEFAULT
- -nr, --num-rows <num_rows>¶
Number of rows to show.
- -nc, --num-cols <num_cols>¶
Number of cols to show.
Arguments
- QUERY¶
Required argument