Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch mode #579

Open
suhlig opened this issue Jun 20, 2021 · 1 comment
Open

Batch mode #579

suhlig opened this issue Jun 20, 2021 · 1 comment

Comments

@suhlig
Copy link
Contributor

suhlig commented Jun 20, 2021

Thanks for this project; very useful.

I would be interested in running this in batch mode; i.e. specifying the query on stdin or in a file. I could then make csv-sql part of shell pipelines and run it in continuous integration.

Something like this syntax comes to mind:

$ echo '.export(results.csv) SELECT COUNT(*) from t;' | csvsql file.csv

Alternatively, reading the query from a file would also be useful:

$ echo '.export(results.csv) SELECT COUNT(*) from t;' > query.sql
$ csvsql file.csv --load-query-from query.sql

If --load-query-from would accept - as a symbol for stdin, the line would look like this:

$ echo '.export(results.csv) SELECT COUNT(*) from t;' | csvsql file.csv --load-query-from -

Personally, the first option (read query from stdin if it's not a TTY) would be my preference.

@alex
Copy link
Owner

alex commented Jun 21, 2021

I think what I'd go with is --query which takes a SQL string (not a path to a file). One can easily specify do csvsql file.csv --query $(cat foo.sql) then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants