Skip to content

Conversation

@rolandwalker
Copy link
Contributor

Description

Support a --checkpoint file for batch input which saves only successful queries, not results.

The motivation is that a checkpoint file allows an operator to resume an interrupted script. The --logfile option is inconvenient for this since it logs results.

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.

@rolandwalker rolandwalker self-assigned this Jan 22, 2026
@rolandwalker rolandwalker force-pushed the RW/checkpoint-file-for-batch-input branch 2 times, most recently from b68332f to 560ba31 Compare January 22, 2026 16:55
mycli/main.py Outdated
assert self.sqlexecute is not None
self.log_query(query)
results = self.sqlexecute.run(query)
if checkpoint:
Copy link
Contributor

Choose a reason for hiding this comment

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

This logs the query before it finishes running; is that the intended use case? I would expect it to log after completion under normal circumstances. If so could be moved down below the for loop and then it will write after. Also would recommend using write instead of print, and you can flush it so the log gets updated right away for tracking purposes:

        if checkpoint:
            checkpoint.write(query)
            checkpoint.flush()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch/es!

Updated, with a test to cover query failure.

@rolandwalker rolandwalker force-pushed the RW/checkpoint-file-for-batch-input branch 2 times, most recently from 626c8de to e3b3e04 Compare January 23, 2026 12:04
which saves only successful queries, not results.
@rolandwalker rolandwalker force-pushed the RW/checkpoint-file-for-batch-input branch from e3b3e04 to b86cb3d Compare January 23, 2026 17:54
@rolandwalker rolandwalker merged commit ce86688 into main Jan 23, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/checkpoint-file-for-batch-input branch January 23, 2026 17:58
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