sqlq v0.0.4
SQLQ
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 sqlqThen, you should be able to view the application help using:
sqlq helpWhich 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.Usage
The flow for using the application is as follows:
- Create a connection to a database using
sqlq connection createand 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 sqlorsqlq query filesubcommands - You can also store queries to run by name using the
sqlq toolsubcommand set - The application stores previous queries which can be accessed using
sqlq history. You can repeat these queries using their ID withsqlq query history
Supported Databases
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
Features
- 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
Maybe to do
- 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?
Commands
sqlq conn create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]sqlq conn delete ALIASsqlq conn get ALIASsqlq conn ls [SEARCH]sqlq connection create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]sqlq connection delete ALIASsqlq connection get ALIASsqlq connection list [SEARCH]sqlq connection ls [SEARCH]sqlq connection update ALIAS CONNECTIONSTRING [DESCRIPTION]sqlq help [COMMANDS]sqlq history delete IDsqlq history get IDsqlq history list [SEARCH]sqlq history ls [SEARCH]sqlq query file ALIAS FILEsqlq query history IDsqlq query sql ALIAS QUERYsqlq query tool ALIAS NAMEsqlq tool create NAME QUERY [DESCRIPTION]sqlq tool delete NAMEsqlq tool get NAMEsqlq tool list [SEARCH]sqlq tool ls [SEARCH]sqlq tool update NAME [QUERY] [DESCRIPTION]sqlq yeet DRIVER CONNECTIONSTRING QUERY
sqlq conn create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]
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;sqlq conn delete ALIAS
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 deletesqlq conn get ALIAS
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 getsqlq conn ls [SEARCH]
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 lssqlq connection create DRIVER ALIAS CONNECTIONSTRING [DESCRIPTION]
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
sqlq connection delete ALIAS
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 deleteSee code: src/commands/connection/delete.ts
sqlq connection get ALIAS
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 getSee code: src/commands/connection/get.ts
sqlq connection list [SEARCH]
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 lsSee code: src/commands/connection/list.ts
sqlq connection ls [SEARCH]
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 lssqlq connection update ALIAS CONNECTIONSTRING [DESCRIPTION]
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 connectionSee code: src/commands/connection/update.ts
sqlq help [COMMANDS]
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
sqlq history delete ID
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 entrySee code: src/commands/history/delete.ts
sqlq history get ID
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 entrySee code: src/commands/history/get.ts
sqlq history list [SEARCH]
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 lsSee code: src/commands/history/list.ts
sqlq history ls [SEARCH]
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 lssqlq query file ALIAS FILE
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 fileSee code: src/commands/query/file.ts
sqlq query history ID
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 querySee code: src/commands/query/history.ts
sqlq query sql ALIAS QUERY
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 databaseSee code: src/commands/query/sql.ts
sqlq query tool ALIAS NAME
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 connectionSee code: src/commands/query/tool.ts
sqlq tool create NAME QUERY [DESCRIPTION]
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 toolSee code: src/commands/tool/create.ts
sqlq tool delete NAME
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 toolSee code: src/commands/tool/delete.ts
sqlq tool get NAME
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 toolSee code: src/commands/tool/get.ts
sqlq tool list [SEARCH]
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 lsSee code: src/commands/tool/list.ts
sqlq tool ls [SEARCH]
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 lssqlq tool update NAME [QUERY] [DESCRIPTION]
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 toolSee code: src/commands/tool/update.ts
sqlq yeet DRIVER CONNECTIONSTRING QUERY
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