A little CLI for working with databases during development for quick queries and automation
Install the CLI from NPM using your fave package manager. If you don't have a fave, just use npm
:
npm install --global sqlq
Then, you should be able to view the application help using:
sqlq help
Which should show you the root help menu:
Quickly interact with your development databases
VERSION
sqlq/0.0.2 win32-x64 node-v20.10.0
USAGE
$ sqlq [COMMAND]
TOPICS
connection Create a connection to a database
history Delete a history entry
query Query data from a database by file
tool Create a tool
COMMANDS
help Display help for sqlq.
yeet Run a query via connection string. Not saved in history.
The flow for using the application is as follows:
- Create a connection to a database using
sqlq connection create
and follow the instructions. This stores the database config so you can connect and use it - Once you have a connection, you can run queries against it using the
sqlq query sql
orsqlq query file
subcommands - You can also store queries to run by name using the
sqlq tool
subcommand set - The application stores previous queries which can be accessed using
sqlq history
. You can repeat these queries using their ID withsqlq query history
Currently the application supports:
- SQLite
- Connection String as pth to the DB File:
./mydatabase.db
. Relative paths may be used but will be resolved from the current directory - Uses sqlite
- Connection String as pth to the DB File:
- PostgreSQL
- Connection String in Postgres format:
postgres://username:password@hostname:PORT/databasename
- Uses pg
- Connection String in Postgres format:
- Microsoft SQL Server
- Connection String in SQL Server Format:
Server=hostname:PORT;Database=databasename;User Id=username;Password=password;Trusted_Connection=True;
. Can also addEncrypt=False;
to the end for working with dbs - Uses mssql
- Connection String in SQL Server Format:
Contributions welcome for additional database support
- Run a single query or a file against any supported database connection
- Manage database connections
- Run queries against a database connection
- Create reusable and parameterized queries
- View history of queries that were run
- Export/save data or use some kind of local connections config file for sharing between people
- Creation of DB instances on the user's machine - SQLite? PG? Docker?
- Run a parameterized query using a CSV for multiple inputs?
sqlq conn create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]
sqlq conn delete ALIAS
sqlq conn get ALIAS
sqlq conn ls [SEARCH]
sqlq connection create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]
sqlq connection delete ALIAS
sqlq connection get ALIAS
sqlq connection list [SEARCH]
sqlq connection ls [SEARCH]
sqlq connection update ALIAS CONNECTIONSTRING [DESCRIPTION]
sqlq help [COMMANDS]
sqlq history delete ID
sqlq history get ID
sqlq history list [SEARCH]
sqlq history ls [SEARCH]
sqlq query file ALIAS FILE
sqlq query history ID
sqlq query sql ALIAS QUERY
sqlq query tool ALIAS NAME
sqlq tool create NAME QUERY [DESCRIPTION]
sqlq tool delete NAME
sqlq tool get NAME
sqlq tool list [SEARCH]
sqlq tool ls [SEARCH]
sqlq tool update NAME [QUERY] [DESCRIPTION]
sqlq yeet DRIVER CONNECTIONSTRING QUERY
Create a connection to a database
USAGE
$ sqlq conn create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv]
[--outfile <value>]
ARGUMENTS
DRIVER (mssql|sqlite|pg) The type of driver to use when working to the database
ALIAS Alias for connection
CONNECTIONSTRING Connection string for database
DESCRIPTION Description of connection
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Create a connection to a database
ALIASES
$ sqlq conn create
EXAMPLES
$ sqlq connection create sqlite my-sqlite-db /path/to/file.db
$ sqlq connection create pg postgres://username:password@hostname:PORT/databasename
$ sqlq connection create mssql Server=hostname:PORT;Database=databasename;User Id=username;Password=password;Trusted_Connection=True;
Delete a connection
USAGE
$ sqlq conn delete ALIAS [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias of connection to delete
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a connection
ALIASES
$ sqlq conn delete
Get connection
USAGE
$ sqlq conn get ALIAS [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias for connection
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get connection
ALIASES
$ sqlq conn get
List all saved connections
USAGE
$ sqlq conn ls [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
SEARCH Search for a connection by alias, description, or conection string
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
List all saved connections
ALIASES
$ sqlq connection ls
$ sqlq conn ls
Create a connection to a database
USAGE
$ sqlq connection create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv]
[--outfile <value>]
ARGUMENTS
DRIVER (mssql|sqlite|pg) The type of driver to use when working to the database
ALIAS Alias for connection
CONNECTIONSTRING Connection string for database
DESCRIPTION Description of connection
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Create a connection to a database
ALIASES
$ sqlq conn create
EXAMPLES
$ sqlq connection create sqlite my-sqlite-db /path/to/file.db
$ sqlq connection create pg postgres://username:password@hostname:PORT/databasename
$ sqlq connection create mssql Server=hostname:PORT;Database=databasename;User Id=username;Password=password;Trusted_Connection=True;
See code: src/commands/connection/create.ts
Delete a connection
USAGE
$ sqlq connection delete ALIAS [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias of connection to delete
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a connection
ALIASES
$ sqlq conn delete
See code: src/commands/connection/delete.ts
Get connection
USAGE
$ sqlq connection get ALIAS [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias for connection
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get connection
ALIASES
$ sqlq conn get
See code: src/commands/connection/get.ts
List all saved connections
USAGE
$ sqlq connection list [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
SEARCH Search for a connection by alias, description, or conection string
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
List all saved connections
ALIASES
$ sqlq connection ls
$ sqlq conn ls
See code: src/commands/connection/list.ts
List all saved connections
USAGE
$ sqlq connection ls [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
SEARCH Search for a connection by alias, description, or conection string
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
List all saved connections
ALIASES
$ sqlq connection ls
$ sqlq conn ls
Update a connection
USAGE
$ sqlq connection update ALIAS CONNECTIONSTRING [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv] [--outfile
<value>]
ARGUMENTS
ALIAS Alias for connection
CONNECTIONSTRING Connection string for database
DESCRIPTION Description of connection
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Update a connection
See code: src/commands/connection/update.ts
Display help for sqlq.
USAGE
$ sqlq help [COMMANDS] [-n]
ARGUMENTS
COMMANDS Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for sqlq.
See code: @oclif/plugin-help
Delete a history entry
USAGE
$ sqlq history delete ID [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ID ID of history entry to delete
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a history entry
See code: src/commands/history/delete.ts
Get a history entry
USAGE
$ sqlq history get ID [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ID ID of history entry
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get a history entry
See code: src/commands/history/get.ts
Search query history
USAGE
$ sqlq history list [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--alias <value>]
[--aliasExact] [--count <value>]
ARGUMENTS
SEARCH Part of a query to search for
FLAGS
--alias=<value> Alias for connection
--aliasExact If alias should match exactly
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search query history
ALIASES
$ sqlq history ls
See code: src/commands/history/list.ts
Search query history
USAGE
$ sqlq history ls [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--alias <value>]
[--aliasExact] [--count <value>]
ARGUMENTS
SEARCH Part of a query to search for
FLAGS
--alias=<value> Alias for connection
--aliasExact If alias should match exactly
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search query history
ALIASES
$ sqlq history ls
Query data from a database by file
USAGE
$ sqlq query file ALIAS FILE [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias for connection
FILE Path to file containing SQL query
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Query data from a database by file
See code: src/commands/query/file.ts
Re-run a previous database query
USAGE
$ sqlq query history ID [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--withAlias <value>]
ARGUMENTS
ID ID of history entry to execute
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
--withAlias=<value> Override the initial alias used to run the command
DESCRIPTION
Re-run a previous database query
See code: src/commands/query/history.ts
Query data from a database
USAGE
$ sqlq query sql ALIAS QUERY [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
ALIAS Alias for connection
QUERY Query to run on database
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Query data from a database
See code: src/commands/query/sql.ts
Use a tool with a connection
USAGE
$ sqlq query tool ALIAS NAME [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--params <value>]
ARGUMENTS
ALIAS Connection alias to invoke the tool against
NAME Name of tool to execute
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
--params=<value>... Parameter to use in subcommand
DESCRIPTION
Use a tool with a connection
See code: src/commands/query/tool.ts
Create a tool
USAGE
$ sqlq tool create NAME QUERY [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
NAME Name for the tool
QUERY A query that the tool will run. This may contain parameters in the format of $Index that will be
evaluated when the query runs
DESCRIPTION Description for the tool
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Create a tool
See code: src/commands/tool/create.ts
Delete a tool
USAGE
$ sqlq tool delete NAME [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
NAME Name of tool to delete
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a tool
See code: src/commands/tool/delete.ts
Get a tool
USAGE
$ sqlq tool get NAME [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
NAME Name of tool
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get a tool
See code: src/commands/tool/get.ts
Search tools
USAGE
$ sqlq tool list [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--count <value>]
ARGUMENTS
SEARCH Part of a query to search for
FLAGS
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search tools
ALIASES
$ sqlq tool ls
See code: src/commands/tool/list.ts
Search tools
USAGE
$ sqlq tool ls [SEARCH] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>] [--count <value>]
ARGUMENTS
SEARCH Part of a query to search for
FLAGS
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search tools
ALIASES
$ sqlq tool ls
Update a tool
USAGE
$ sqlq tool update NAME [QUERY] [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
NAME Name for the tool
QUERY A query that the tool will run. This may contain parameters in the format of $Index that will be
evaluated when the query runs
DESCRIPTION Description for the tool
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Update a tool
See code: src/commands/tool/update.ts
Run a query via connection string. Not saved in history.
USAGE
$ sqlq yeet DRIVER CONNECTIONSTRING QUERY [--format js|table|json|yml|yaml|csv|ssv] [--outfile <value>]
ARGUMENTS
DRIVER (mssql|sqlite|pg) Database driver to use
CONNECTIONSTRING Connection String
QUERY Query to run on database
FLAGS
--format=<option> [default: table]
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Run a query via connection string. Not saved in history.
See code: src/commands/yeet.ts