Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling a query leads to an error message, there is no 'KILL' command in sqlite #164

Closed
mjpieters opened this issue Sep 20, 2023 · 1 comment · Fixed by #166
Closed

Comments

@mjpieters
Copy link
Contributor

mjpieters commented Sep 20, 2023

On keyboard interrupt during a long-running query, an error message is printed:

Encountered error while cancelling query: near "kill": syntax error

That's because litecli tries to treat sqlite like a remote database and sends a kill <connectionid> command, which sqlite doesn't support.

Instead, litecli should call the connection.interrupt() method. No new connection is needed. In main.py:LiteCli.one_iteration(), replace the last KeyboardInterrupt exception handler with:

            except KeyboardInterrupt:
                try:
                    sqlexecute.conn.interrupt()
                except Exception as e:
                    self.echo(
                        "Encountered error while cancelling query: {}".format(e),
                        err=True,
                        fg="red",
                    )
                else:
                    logger.debug("cancelled query")
                    self.echo("cancelled query", err=True, fg="red")
@amjith
Copy link
Member

amjith commented Sep 21, 2023

Do you mind making a PR?

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 a pull request may close this issue.

2 participants