-
Notifications
You must be signed in to change notification settings - Fork 5
Command line interface
mhkeller edited this page Feb 5, 2014
·
9 revisions
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.
- Specify the
IN_FILEwith-i.
Optionally:
- To only print the
CREATEcommands and not theINSERTcommands 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 -- supportscsv,json,tsvandpsv(pipe-separated values). - Specify a table name with
-n. Defaults totsif 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.
- Specify the
IN_FILEwith-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 -- supportscsv,json,tsvandpsv(pipe-separated values). - Specify a table name with
-n. Defaults totsif nothing specified. - Specify an output file with
-o. Name must end in either.csvor.json. This extension will determine the format of your file. If-onot specified, your query result will print to the console. - Specify a database connection with
-c. Defaults topg://postgres:5432@localhost. Read more about database connections.
- Specify the
IN_FILEwith-i. - Specify the mode as
createwith-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 -- supportscsv,json,tsvandpsv(pipe-separated values). - Specify a table name with
-n. Defaults totsif 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 topg://postgres:5432@localhost. Read more about database connections.
- Specify the query with
-q, e.g.-q "SELECT * FROM ts;"
Optionally:
- Specify an output file with
-o. Name must end in either.csvor.json. This extension will determine the format of your file. If-onot specified, your query result will print to the console. - Specify a database connection with
-c. Defaults topg://postgres:5432@localhost. Read more about database connections.