Skip to content

Conversation

@scottnemes
Copy link
Contributor

Description

Currently the watch command execution time is wrong for the 2nd+ iteration as it includes the execution time plus the watch command time. This PR fixes that issue so the correct execution time is reported for all watch iterations.

Fixes #763

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.

@scottnemes
Copy link
Contributor Author

@rolandwalker Let me know if this looks better. I was hoping to not have to include it in the iterator, but I do not see another way around that unless we get rid of the iterator bit to begin with. Could potentially just next(res) it each time and then use the dataclass without iteration (i.e. no for loop at all), but not sure if that is any less hacky or would even work. So if you know a better way to do that let me know

set_pager_enabled(False)
for sql, title in sql_list:
cur.execute(sql)
command = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a dict instead of two new properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't want to add a bunch of random properties (presuming other commands will need other args), so figured a general command property with the dict that could be added to as needed would be better. But if you prefer having standalone properties for it all I can do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation, your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll keep it as-is then. Don't want to make too many assumptions about future use since this is the first use case, and it can be adjusted later if we find another approach makes more sense given new use cases. Current imagined use case is other commands needing special args, and it fits that anyway.

@scottnemes scottnemes marked this pull request as draft January 10, 2026 21:38
@scottnemes scottnemes marked this pull request as ready for review January 10, 2026 21:44
@rolandwalker rolandwalker merged commit e67744c into dbcli:main Jan 10, 2026
8 checks passed
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.

Query time output when using watch includes the watch time

2 participants