Skip to content

Conversation

@rolandwalker
Copy link
Contributor

Description

Accept multiple --execute options and run each specified query in turn

The current behavior is to accept multiple --execute options, but to only execute the last one: a bug.

Since there are multiple values, we can also support --throttle, per the discussion in #1460.

One inconsistency between STDIN and --execute is that --execute does not support warning on destructive queries. This should probably be resolved in the direction of removing the warning from scripts on STDIN.

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format && uv run mypy --install-types . to lint and format the code.

and run each specified query in turn.

The current behavior is to accept multiple --execute options, but to
only execute the last one: a bug.

Since there are multiple values, we can also support --throttle, per
the discussion in #1460.

One inconsistency between STDIN and --execute is that --execute does
not support warning on destructive queries.  This should probably
be resolved in the direction of removing the warning from scripts on
STDIN.
@rolandwalker rolandwalker self-assigned this Jan 24, 2026
@scottnemes
Copy link
Contributor

What is the benefit of multiple executes over running multiple queries within a single execute like you would normally?

I.e.

mycli -e "select 1; select 2; select 3"

vs

mycli -e "select 1" -e "select 2" -e "select 3"

Unless there is a specific use case that seems unnecessary. My original comment was around the fact that you could technically have the throttle affect the multiple queries passed at once, since we parse the queries one by one anyway.

@rolandwalker
Copy link
Contributor Author

The benefits are:

  • unify the two batch modes with the same behavior
  • fix an untenable bug: only the last --execute was (silently) respected

@scottnemes
Copy link
Contributor

The benefits are:

  • unify the two batch modes with the same behavior
  • fix an untenable bug: only the last --execute was (silently) respected

Unclear why you need multiple -e params to unify the batch modes? RE: the multiple -e bug, I'd lean towards checking for that scenario and erroring vs adding it in as functionality to avoid the bug. The behavior of accepting multiple is the same for all "basic" options, so we'd be selectively changing that in this case.

mycli -u scottn -u noob
(1045, "Access denied for user 'noob'@'localhost' (using password: NO)")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants