Skip to content

Commit

Permalink
📝 usage overview
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelvalley committed Dec 9, 2023
1 parent 2e1c26b commit c90d7fb
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ node_modules
node_modules
oclif.lock
oclif.manifest.json
/prisma/app.db
/prisma/app.db-journal
/prisma/sqlq.db
/prisma/sqlq.db-journal
/sample.db
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

A little CLI for working with databases during development for quick queries and automation

# Usage

Install the CLI from NPM using your fave package manager. If you don't have a fave, just use `npm`:

```sh
npm install --global sqlq
```

Then, you should be able to view the application help using:

```sh
sqlq help
```

The flow for using the application is as follows:

1. 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
2. Once you have a connection, you can run queries against it using the `sqlq query sql` or `sqlq query file` subcommands
3. You can also store queries to run by name using the `sqlq tool` subcommand set
4. The application stores previous queries which can be accessed using `sqlq history`. You can repeat these queries using their ID with `sqlq query history`

# Supported Databases

Currently the application should work fine with:

1. SQLite
2. PostgreSQL
3. Microsoft SQL Server

> Contributions welcome for additional database support
# Goals

- [x] Manage list of connections
Expand All @@ -23,5 +54,6 @@ A little CLI for working with databases during development for quick queries and
- [`sqlq history`](docs/history.md) - Delete a history entry
- [`sqlq query`](docs/query.md) - Query data from a database by file
- [`sqlq tool`](docs/tool.md) - Create a tool
- [`sqlq yeet`](docs/yeet.md) - Run a query via connection string. Not saved in history.

<!-- commandsstop -->
2 changes: 0 additions & 2 deletions data.csv

This file was deleted.

26 changes: 16 additions & 10 deletions docs/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Create a connection to a database

```
USAGE
$ sqlq connection create ALIAS DRIVER CONNECTIONSTRING [DESCRIPTION] [--format js|table|json|csv]
$ sqlq connection create ALIAS DRIVER CONNECTIONSTRING [DESCRIPTION] [--format js|table|json|yml|yaml|csv|ssv]
[--outfile <value>]
ARGUMENTS
ALIAS Alias for connection
Expand All @@ -25,7 +26,8 @@ ARGUMENTS
FLAGS
--format=<option> [default: table]
<options: js|table|json|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Create a connection to a database
Expand All @@ -42,14 +44,15 @@ Delete a connection

```
USAGE
$ sqlq connection delete ALIAS [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a connection
Expand All @@ -66,14 +69,15 @@ Get connection

```
USAGE
$ sqlq connection get ALIAS [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get connection
Expand All @@ -90,14 +94,15 @@ List all saved connections

```
USAGE
$ sqlq connection list [SEARCH] [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
List all saved connections
Expand All @@ -115,14 +120,15 @@ List all saved connections

```
USAGE
$ sqlq connection ls [SEARCH] [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
List all saved connections
Expand Down
43 changes: 14 additions & 29 deletions docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ Delete a history entry
* [`sqlq history get ID`](#sqlq-history-get-id)
* [`sqlq history list [SEARCH]`](#sqlq-history-list-search)
* [`sqlq history ls [SEARCH]`](#sqlq-history-ls-search)
* [`sqlq history query ID`](#sqlq-history-query-id)

## `sqlq history delete ID`

Delete a history entry

```
USAGE
$ sqlq history delete ID [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Delete a history entry
Expand All @@ -36,14 +36,15 @@ Get a history entry

```
USAGE
$ sqlq history get ID [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Get a history entry
Expand All @@ -57,7 +58,8 @@ Search query history

```
USAGE
$ sqlq history list [SEARCH] [--format js|table|json|csv] [--alias <value>] [--aliasExact] [--count <value>]
$ 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
Expand All @@ -67,7 +69,8 @@ FLAGS
--aliasExact If alias should match exactly
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search query history
Expand All @@ -84,7 +87,8 @@ Search query history

```
USAGE
$ sqlq history ls [SEARCH] [--format js|table|json|csv] [--alias <value>] [--aliasExact] [--count <value>]
$ 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
Expand All @@ -94,31 +98,12 @@ FLAGS
--aliasExact If alias should match exactly
--count=<value> [default: 20] Maximum number of results to return
--format=<option> [default: table]
<options: js|table|json|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Search query history
ALIASES
$ sqlq history ls
```

## `sqlq history query ID`

Re-run a previous database query

```
USAGE
$ sqlq history query ID [--format js|table|json|csv] [--withAlias <value>]
ARGUMENTS
ID ID of history entry to execute
FLAGS
--format=<option> [default: table]
<options: js|table|json|csv>
--withAlias=<value> Override the initial alias used to run the command
DESCRIPTION
Re-run a previous database query
```
59 changes: 55 additions & 4 deletions docs/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,99 @@
Query data from a database by file

* [`sqlq query file ALIAS FILE`](#sqlq-query-file-alias-file)
* [`sqlq query history ID`](#sqlq-query-history-id)
* [`sqlq query sql ALIAS QUERY`](#sqlq-query-sql-alias-query)
* [`sqlq query tool ALIAS NAME`](#sqlq-query-tool-alias-name)

## `sqlq query file ALIAS FILE`

Query data from a database by file

```
USAGE
$ sqlq query file ALIAS FILE [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Query data from a database by file
```

_See code: [dist/commands/query/file.ts](https://github.com/nabeelvalley/sqlq/blob/v0.0.0/dist/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 query
```

_See code: [dist/commands/query/history.ts](https://github.com/nabeelvalley/sqlq/blob/v0.0.0/dist/commands/query/history.ts)_

## `sqlq query sql ALIAS QUERY`

Query data from a database

```
USAGE
$ sqlq query sql ALIAS QUERY [--format js|table|json|csv]
$ 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|csv>
<options: js|table|json|yml|yaml|csv|ssv>
--outfile=<value> Print output to file
DESCRIPTION
Query data from a database
```

_See code: [dist/commands/query/sql.ts](https://github.com/nabeelvalley/sqlq/blob/v0.0.0/dist/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 connection
```

_See code: [dist/commands/query/tool.ts](https://github.com/nabeelvalley/sqlq/blob/v0.0.0/dist/commands/query/tool.ts)_
Loading

0 comments on commit c90d7fb

Please sign in to comment.