Skip to content
Open
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
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down