Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions mycli/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Contributors:
* 924060929
* tmijieux
* Scott Nemes
* Angelino Storm


Created by:
Expand Down
1 change: 1 addition & 0 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions mycli/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions mycli/packages/special/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
is_expanded_output,
is_pager_enabled,
is_redirected,
is_show_favorite_query,
is_timing_enabled,
open_external_editor,
set_delimiter,
Expand All @@ -27,6 +28,7 @@
set_pager,
set_pager_enabled,
set_redirect,
set_show_favorite_query,
set_timing_enabled,
split_queries,
unset_once_if_written,
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 11 additions & 1 deletion mycli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]",
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions test/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down