From f5c3d0909bf0b40d2a8058baaacb748bfa123ee5 Mon Sep 17 00:00:00 2001 From: Angelino Date: Wed, 7 Jan 2026 03:36:49 +0100 Subject: [PATCH 1/4] implementation of new config --- changelog.md | 1 + mycli/AUTHORS | 1 + mycli/main.py | 1 + mycli/myclirc | 3 +++ mycli/packages/special/__init__.py | 4 ++++ mycli/packages/special/iocommands.py | 12 +++++++++++- test/myclirc | 3 +++ 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b7c4865b..338f011d 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ Features -------- * Add enum value completions for WHERE/HAVING clauses. (#790) +* Add `favorite_query_show_query` config option to control query printing when running favorite queries. (#1118) 1.43.1 (2026/01/03) diff --git a/mycli/AUTHORS b/mycli/AUTHORS index fc4cc4d3..d3bfe89a 100644 --- a/mycli/AUTHORS +++ b/mycli/AUTHORS @@ -112,6 +112,7 @@ Contributors: * 924060929 * tmijieux * Scott Nemes + * Angelino Storm Created by: diff --git a/mycli/main.py b/mycli/main.py index faf5c406..85b87006 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -135,6 +135,7 @@ def __init__( self.multi_line = c["main"].as_bool("multi_line") self.key_bindings = c["main"]["key_bindings"] special.set_timing_enabled(c["main"].as_bool("timing")) + special.set_show_favorite_query(c["main"].as_bool("favorite_query_show_query")) self.beep_after_seconds = float(c["main"]["beep_after_seconds"] or 0) FavoriteQueries.instance = FavoriteQueries.from_config(self.config) diff --git a/mycli/myclirc b/mycli/myclirc index 84d05d21..5ca1d4b9 100644 --- a/mycli/myclirc +++ b/mycli/myclirc @@ -41,6 +41,9 @@ log_level = INFO # Timing of SQL statements and table rendering, or LLM commands. timing = True +# Show the full SQL when running a favorite query. Set to False to hide. +favorite_query_show_query = True + # Beep after long-running queries are completed; 0 to disable. beep_after_seconds = 0 diff --git a/mycli/packages/special/__init__.py b/mycli/packages/special/__init__.py index e9d1d31e..c96ffcb5 100644 --- a/mycli/packages/special/__init__.py +++ b/mycli/packages/special/__init__.py @@ -18,6 +18,7 @@ is_expanded_output, is_pager_enabled, is_redirected, + is_show_favorite_query, is_timing_enabled, open_external_editor, set_delimiter, @@ -27,6 +28,7 @@ set_pager, set_pager_enabled, set_redirect, + set_show_favorite_query, set_timing_enabled, split_queries, unset_once_if_written, @@ -82,6 +84,8 @@ 'set_pager_enabled', 'set_redirect', 'set_timing_enabled', + 'set_show_favorite_query', + 'is_show_favorite_query', 'special_command', 'split_queries', 'sql_using_llm', diff --git a/mycli/packages/special/iocommands.py b/mycli/packages/special/iocommands.py index 3304ee2a..c2b97ae7 100644 --- a/mycli/packages/special/iocommands.py +++ b/mycli/packages/special/iocommands.py @@ -26,6 +26,7 @@ use_expanded_output = False force_horizontal_output = False PAGER_ENABLED = True +SHOW_FAVORITE_QUERY = True tee_file = None once_file = None written_to_once_file = False @@ -58,6 +59,15 @@ def is_pager_enabled() -> bool: return PAGER_ENABLED +def set_show_favorite_query(val: bool) -> None: + global SHOW_FAVORITE_QUERY + SHOW_FAVORITE_QUERY = val + + +def is_show_favorite_query() -> bool: + return SHOW_FAVORITE_QUERY + + @special_command( "pager", "\\P [command]", @@ -260,7 +270,7 @@ def execute_favorite_query(cur: Cursor, arg: str, **_) -> Generator[tuple, None, else: for sql in sqlparse.split(query): sql = sql.rstrip(";") - title = f"> {sql}" + title = f"> {sql}" if is_show_favorite_query() else None cur.execute(sql) if cur.description: headers = [x[0] for x in cur.description] diff --git a/test/myclirc b/test/myclirc index facdb12d..16343390 100644 --- a/test/myclirc +++ b/test/myclirc @@ -41,6 +41,9 @@ log_level = DEBUG # Timing of sql statements and table rendering. timing = True +# Show the full SQL when running a favorite query. Set to False to hide. +favorite_query_show_query = True + # Beep after long-running queries are completed; 0 to disable. beep_after_seconds = 0 From 01b8149e92961d9963c3ce1dbc585b16e2969597 Mon Sep 17 00:00:00 2001 From: Angelino Date: Wed, 7 Jan 2026 03:37:46 +0100 Subject: [PATCH 2/4] make mypy happy adds an unreachable return, because `uv run mypy --install-types .` complains about a missing return statement in this method, even though there is a `self.fail` before it. --- mycli/packages/prompt_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mycli/packages/prompt_utils.py b/mycli/packages/prompt_utils.py index 839fdcf6..bc9e98e7 100644 --- a/mycli/packages/prompt_utils.py +++ b/mycli/packages/prompt_utils.py @@ -17,6 +17,7 @@ def convert(self, value: bool | str, param: click.Parameter | None, ctx: click.C if value in ("no", "n"): return False self.fail(f'{value} is not a valid boolean', param, ctx) + return False def __repr__(self): return "BOOL" From def752e9712d26c8f8afe1e0a51d6ffc4166afe4 Mon Sep 17 00:00:00 2001 From: Angelino Date: Wed, 7 Jan 2026 03:47:32 +0100 Subject: [PATCH 3/4] make mypy happy mypy now complained about unreachable statement, reverting previous commit 01b8149e92961d9963c3ce1dbc585b16e2969597 --- mycli/packages/prompt_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mycli/packages/prompt_utils.py b/mycli/packages/prompt_utils.py index bc9e98e7..839fdcf6 100644 --- a/mycli/packages/prompt_utils.py +++ b/mycli/packages/prompt_utils.py @@ -17,7 +17,6 @@ def convert(self, value: bool | str, param: click.Parameter | None, ctx: click.C if value in ("no", "n"): return False self.fail(f'{value} is not a valid boolean', param, ctx) - return False def __repr__(self): return "BOOL" From 77b0debd2533dd111b1373bf17010c10af7e30ab Mon Sep 17 00:00:00 2001 From: Angelino Date: Thu, 8 Jan 2026 03:07:32 +0100 Subject: [PATCH 4/4] favorite_query_show_query -> show_favorite_query --- changelog.md | 2 +- mycli/main.py | 2 +- mycli/myclirc | 2 +- test/myclirc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 338f011d..02a54ac2 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,7 @@ Features -------- * Add enum value completions for WHERE/HAVING clauses. (#790) -* Add `favorite_query_show_query` config option to control query printing when running favorite queries. (#1118) +* Add `show_favorite_query` config option to control query printing when running favorite queries. (#1118) 1.43.1 (2026/01/03) diff --git a/mycli/main.py b/mycli/main.py index 85b87006..226252f3 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -135,7 +135,7 @@ def __init__( self.multi_line = c["main"].as_bool("multi_line") self.key_bindings = c["main"]["key_bindings"] special.set_timing_enabled(c["main"].as_bool("timing")) - special.set_show_favorite_query(c["main"].as_bool("favorite_query_show_query")) + special.set_show_favorite_query(c["main"].as_bool("show_favorite_query")) self.beep_after_seconds = float(c["main"]["beep_after_seconds"] or 0) FavoriteQueries.instance = FavoriteQueries.from_config(self.config) diff --git a/mycli/myclirc b/mycli/myclirc index 5ca1d4b9..62353c9e 100644 --- a/mycli/myclirc +++ b/mycli/myclirc @@ -42,7 +42,7 @@ log_level = INFO timing = True # Show the full SQL when running a favorite query. Set to False to hide. -favorite_query_show_query = True +show_favorite_query = True # Beep after long-running queries are completed; 0 to disable. beep_after_seconds = 0 diff --git a/test/myclirc b/test/myclirc index 16343390..f4f0ff09 100644 --- a/test/myclirc +++ b/test/myclirc @@ -42,7 +42,7 @@ log_level = DEBUG timing = True # Show the full SQL when running a favorite query. Set to False to hide. -favorite_query_show_query = True +show_favorite_query = True # Beep after long-running queries are completed; 0 to disable. beep_after_seconds = 0