From 8cb611d73b088c3f953cb4945e9cd85f5134bc30 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Tue, 20 Jan 2026 07:33:45 -0500 Subject: [PATCH 1/2] stream input from stdin rather than reading the entire script into memory. * Stream STDIN input, running queries a line at a time. * Remove MemoryError check, and recommendation for the vendor client. * Use CSV/TSV formats with headers for the first line only. * Exit with an error code if we are unable to open /dev/tty. * Add --noninteractive flag to suppress the destructive-warning prompt from the CLI. * Add --format= option to control output formats, leaving the default format as "extra headers pseudo TSV". * Commentary on edge cases and followups. --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index d8beb865..6fc7dde6 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,7 @@ Features * Allow history file location to be configured. * Make destructive-warning keywords configurable. * Smarter fuzzy completion matches. +* Stream input from STDIN to consume less memory, adding `--noninteractive` and `--format=` CLI arguments. Bug Fixes From f37a0b25ffe73148104f4e5693e8f305e62f0ee3 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 21 Jan 2026 14:47:08 -0500 Subject: [PATCH 2/2] add --throttle option for batch mode pauses The --throttle option adds a pause between queries in batch mode, which can be useful for long or intensive scripts. Technically we pause between each line of input, which is usually equivalent to one query. --- changelog.md | 1 + mycli/main.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 6fc7dde6..ab4ef41d 100644 --- a/changelog.md +++ b/changelog.md @@ -26,6 +26,7 @@ Features * Make destructive-warning keywords configurable. * Smarter fuzzy completion matches. * Stream input from STDIN to consume less memory, adding `--noninteractive` and `--format=` CLI arguments. +* Add `--throttle` option for batch mode. Bug Fixes diff --git a/mycli/main.py b/mycli/main.py index dccbb7f7..9b073943 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -19,7 +19,7 @@ from importlib import resources import itertools from random import choice -from time import time +from time import sleep, time from urllib.parse import parse_qs, unquote, urlparse from cli_helpers.tabular_output import TabularOutputFormatter, preprocessors @@ -1536,6 +1536,7 @@ def get_last_query(self) -> str | None: @click.option( '--format', 'batch_format', type=click.Choice(['default', 'csv', 'tsv', 'table']), help='Format for batch or --execute output.' ) +@click.option('--throttle', type=float, default=0.0, help='Pause in seconds between queries in batch mode.') @click.pass_context def cli( ctx: click.Context, @@ -1585,6 +1586,7 @@ def cli( password_file: str | None, noninteractive: bool, batch_format: str | None, + throttle: float, ) -> None: """A MySQL terminal client with auto-completion and syntax highlighting. @@ -1909,6 +1911,8 @@ def cli( try: if warn_confirmed: mycli.run_query(stdin_text, new_line=True) + if throttle: + sleep(throttle) except Exception as e: click.secho(str(e), err=True, fg="red") sys.exit(1)