diff --git a/changelog.md b/changelog.md index d8beb865..ab4ef41d 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,8 @@ 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. +* 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)