Command line interface - ajam/tablespoon GitHub Wiki

tablespoon  -h, --help
            -i, --in_file    IN_FILE 
            -f, --format     (csv|json|tsv|psv|DELIMITER) 
            -n, --name       TABLE_NAME 
            -o, --out        OUT_FILE 
            -q, --query      "QUERY" 
            -s, --schema     "SCHEMA" 
            -m, --mode       (create|skip-insert)
            -v, --flavor     (sqlite|pgsql)
            -c, --connection DATABASE_CONNECTION

Note: All commands on the database are run with CREATE TEMP TABLE so as not to alter your existing PostgreSQL tables. Only if you specify -m create will a table be added to your database outside of this query session. To delete a table, run tablespoon -q "DROP TABLE <table_name>;"

Defaults for -v, --flavor and -c, --connection come from config.sample.json or config.json if it exists.

So you want to..

Print sql commands

  • Specify the IN_FILE with -i.

Optionally:

  • To only print the CREATE commands and not the INSERT commands use -m skip-insert.
  • Specify an input file format or custom delimeter with -f. If you don't, Tablespoon will attempt to read the file extension -- supports csv, json, tsv and psv (pipe-separated values).
  • Specify a table name with -n. Defaults to ts if nothing specified.
  • Specify an output file with -o. If you don't, sql commands will print to the console.
  • Specify a schema with -s. If you don't, Tablespoon will attempt to read your schema from the specified input file.

Query a data file

  • Specify the IN_FILE with -i.
  • Specify the query with -q, e.g. -q "SELECT * FROM ts;"

Optionally:

  • Specify an input file format or custom delimeter with -f. If you don't, Tablespoon will attempt to read the file extension -- supports csv, json, tsv and psv (pipe-separated values).
  • Specify a table name with -n. Defaults to ts if nothing specified.
  • Specify an output file with -o. Name must end in either .csv or .json. This extension will determine the format of your file. If -o not specified, your query result will print to the console.
  • Specify a database connection with -c. Defaults to pg://postgres:5432@localhost. Read more about database connections.

Create a table in your PostgreSQL database from a file, optionally querying it

  • Specify the IN_FILE with -i.
  • Specify the mode as create with -m create.

Optionally:

  • Specify an input file format or custom delimeter with -f. If you don't, Tablespoon will attempt to read the file extension -- supports csv, json, tsv and psv (pipe-separated values).
  • Specify a table name with -n. Defaults to ts if nothing specified.
  • Specify a schema with -s. If you don't, Tablespoon will attempt to read your schema from the specified input file.
  • Specify a query, see "Query an existing PostgresSQL table" for options.
  • Specify a database connection with -c. Defaults to pg://postgres:5432@localhost. Read more about database connections.

Query an existing PostgreSQL table

  • Specify the query with -q, e.g. -q "SELECT * FROM ts;"

Optionally:

  • Specify an output file with -o. Name must end in either .csv or .json. This extension will determine the format of your file. If -o not specified, your query result will print to the console.
  • Specify a database connection with -c. Defaults to pg://postgres:5432@localhost. Read more about database connections.
⚠️ **GitHub.com Fallback** ⚠️