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

cli:cockroach sql command should have -f option to pass sql file #42955

Closed
dbist opened this issue Dec 4, 2019 · 4 comments · Fixed by #54741
Closed

cli:cockroach sql command should have -f option to pass sql file #42955

dbist opened this issue Dec 4, 2019 · 4 comments · Fixed by #54741
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@dbist
Copy link
Contributor

dbist commented Dec 4, 2019

Is your feature request related to a problem? Please describe.
today, I only see an option of passing a sql command to cockroach sql with --execute flag. I'd like to see an option to pass a file instead. Lack of this ability forces one to do bash trickery to pass a file like so cockroach sql --insecure --host=localhost:26257 --database="tabular_import" --execute="$(< import_statement.sql)

Describe the solution you'd like
a more convenient solution is to see an option to pass a file with a switch like -f

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@dbist dbist added the A-cli label Dec 4, 2019
@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Apr 24, 2020
@knz
Copy link
Contributor

knz commented Apr 24, 2020

@dbist I don't get it - do you know you can do cockroach sql <import_statement.sql

what's wrong with this option?

@dbist
Copy link
Contributor Author

dbist commented Apr 24, 2020

@knz just validated and you're obviously correct, cockroach sql --url 'postgresql://root@localhost:26257?sslcert=certs%2Fclient.root.crt&sslkey=certs%2Fclient.root.key&sslmode=verify-full&sslrootcert=certs%2Fca.crt' < import_statement.sql. I think the fact this information is not readily available calls for a documentation update.

@dbist dbist closed this as completed Apr 24, 2020
@knz
Copy link
Contributor

knz commented Apr 24, 2020

Reopening as discussed: the -f flag can be provided for convenience.

@knz knz reopened this Apr 24, 2020
@dbist
Copy link
Contributor Author

dbist commented Apr 24, 2020

even though ability to pass statement via unix file redirection is available and leveraging psql is also possible, these approaches are not widely understood and don't fall in line with UX. I propose to add a command helper -f and --file similar to psql approach to add to the current cockroach sql arsenal of flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants