turso-cli icon indicating copy to clipboard operation
turso-cli copied to clipboard

Add an option to run a SQL file with `turso db shell`

Open penberg opened this issue 2 years ago • 3 comments

You can currently do cat <file> | turso db shell <name> but let's add an explicit command line option.

penberg avatar Apr 27 '23 10:04 penberg

It's also possible to do this, which is very reasonable: turso db shell $DB < file.sql

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

The question is then: what is the output if processing entirely non-interactively?

CodingDoug avatar Apr 27 '23 11:04 CodingDoug

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

Or maybe just implement a --silent/-s flag, curl style?

psarna avatar May 04 '23 11:05 psarna

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

Or maybe just implement a --silent/-s flag, curl style?

It looks pretty easy to do without an explicit flag: https://stackoverflow.com/questions/43947363/detect-if-a-command-is-piped-or-not

I feel like this sort of detection is pretty normal for unix-y sort of command line tools.

CodingDoug avatar May 04 '23 12:05 CodingDoug