diff --git a/changelog.md b/changelog.md index b7c4865b..02a54ac2 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ Features -------- * Add enum value completions for WHERE/HAVING clauses. (#790) +* 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/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..226252f3 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("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 84d05d21..62353c9e 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. +show_favorite_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..f4f0ff09 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. +show_favorite_query = True + # Beep after long-running queries are completed; 0 to disable. beep_after_seconds = 0