Utilities: Some minor changes in sql REPL tool

- Added a connection banner
- Added '.quit' synonym for '.exit'
- Do not display updated/created/deleted banner if there were no changes
This commit is contained in:
Jan de Visser 2021-07-19 19:50:16 -04:00 committed by Andreas Kling
parent d074a601df
commit 9e43508d30
Notes: sideshowbarker 2024-07-18 05:26:09 +09:00

View File

@ -89,7 +89,7 @@ String read_next_piece()
void handle_command(StringView command) void handle_command(StringView command)
{ {
if (command == ".exit") if (command == ".exit" || command == ".quit")
s_keep_running = false; s_keep_running = false;
else else
outln("\033[33;1mUnrecognized command:\033[0m {}", command); outln("\033[33;1mUnrecognized command:\033[0m {}", command);
@ -174,12 +174,15 @@ int main()
}; };
sql_client->on_connected = [&](int connection_id) { sql_client->on_connected = [&](int connection_id) {
outln("** Connected to {} **", getlogin());
the_connection_id = connection_id; the_connection_id = connection_id;
read_sql(); read_sql();
}; };
sql_client->on_execution_success = [&](int, bool has_results, int updated, int created, int deleted) { sql_client->on_execution_success = [&](int, bool has_results, int updated, int created, int deleted) {
outln("{} row(s) updated, {} created, {} deleted", updated, created, deleted); if (updated != 0 || created != 0 || deleted != 0) {
outln("{} row(s) updated, {} created, {} deleted", updated, created, deleted);
}
if (!has_results) { if (!has_results) {
read_sql(); read_sql();
} }