Open jeromegit opened 3 years ago
Hi,
That feature is already available in mycli, although the syntax is slightly different.
> \| mailx -s "data from MyTable" me@acme.com
> select * from MyTable;
The first command \|
will send the output from the next executed SQL statement to the command specified.
You can find these "special" commands by typing \?
which will list all of them.
I'm not opposed to the idea of making the piping behavior easier to use. So if you find the existing solution less than idea, feel free to send a PR and I'll review it.
Wow, thanks for the super quick response, @amjith! I looked at the doc (https://www.mycli.net/commands) and couldn't find it there.
I'll take a stab at it and see if I can make it work like "\e"
The challenge is detecting the |
symbol in the middle. It was fairly easy to detect \e
or \G
at the end of a query but the |
has to be in the middle and it can also be a legitimate character as part of a SQL query.
@laixintao I remember you implemented this feature in iredis. Do you have any tips?
this line just for highlighter to know this is not a redis command but a shell command.
Except this, I also need to split the input into two parts, one send to redis-server then get the result, then send the result to shell as stdin. (split here ).
And then run the shell, by opening a process (here )
Before I switched to MySQL, I used Sybase for mnay years and to query Sybase I used the wonderful CLI client called sqsh (https://en.wikipedia.org/wiki/Sqsh).
One of the features that sqsh has that I find I'm missing more and more is the "pipe" where one can do something like:
... to easily pipe the output of a query to a shell command. The example above shows a quick way to email the content of a table.
What do you think? I'm happy to take a stab at it too.
Thanks.