neon-cli

Crates.ioneon-cli
lib.rsneon-cli
version0.6.0
sourcesrc
created_at2023-05-18 17:43:31.873728
updated_at2023-05-24 18:31:13.172887
descriptionA command-line tool for using the Neon serverless Postgres database.
homepagehttps://github.com/tullytim/neon-cli
repositoryhttps://github.com/tullytim/neon-cli
max_upload_size
id868203
size577,871
Tim Tully (tullytim)

documentation

README

neon-cli

Neon-CLI is a Rust Crate providing the binary for a command line interface to the Neon Serverless Postgres database.

License: MIT

Usage

Using the CLI is based on commands. Use 'neon-cli' and pass it a command (query, projects, keys, etc) to direct aspect of Neon. Each command takes a varying set of arguments.

% neon-cli 
Neon Postgres Database CLI

Usage: neon-cli [OPTIONS] <COMMAND>

Commands:
  query        Execute a query
  projects     Get information about projects in Neon.
  keys         Get information about keys in Neon.
  branch       Get information about branches in Neon.
  endpoints    Get information about endpoints in Neon.
  operations   Get information about operations in Neon.
  consumption  Get information about consumption in Neon.
  import       Import data from csv file (TEXT only for now).
  help         Print this message or the help of the given subcommand(s)

Options:
  -d, --debug...  
  -h, --help      Print help

Here is an example of the arguments for a given command (query, in this case using --sql or -s to pass a sql statement in.):

% neon-cli query --help
Execute a query

Usage: neon-cli query --sql <SQL>

Options:
  -s, --sql <SQL>  
  -h, --help       Print help

Here is an example of actually using an argument for a given command. Note that "--sql=...." can also be used as -s "select * from ...."

% neon-cli query --sql="select * from foo limit 2;"
Executing query: select * from foo limit 2;
╭──────┬───────┬────────╮
│ bar  ┆ baz   ┆ counts │
╞══════╪═══════╪════════╡
│ test ┆ test2 ┆ 42     │
├╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ test ┆ test2 ┆ 42     │
╰──────┴───────┴────────╯

Importing Data

To import a CSV file, use:


% neon-cli import --help
Import data from csv file (TEXT only for now).

Usage: neon-cli import [OPTIONS] --table <TABLE> --file <FILE>

Options:
  -t, --table <TABLE>          
  -f, --file <FILE>            
  -d, --delimiter <DELIMITER>  
  -h, --help                   Print help

% cat foo.csv
col1,col2,col3
it,works,100
this,is,42

% neon-cli import -f foo.csv -t foo

Configuration (.env file)

Neon-cli uses a dotenv style setup and consumes the typical .env file you're used to. Here is an example outlining all of the env vars neon-cli picks up. If CONNECT_STRING exists, that will be used. Otherwise CONNECT_STRING is built out of HOSTNAME, PORT, etc:

HOSTNAME=a.b.com
PORT=1234
USER=tim
PASSWORD=asdf
DATABASE=neondb
CONNECT_STRING=postgres://tim:ddddddddddd@ep-foo-bar-1111111.us-west-2.aws.neon.tech:5432/neondb
NEON_API_KEY=abcdefghijklmnopkrstuvwxyz123456789987654321

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 60

cargo fmt