tags:

views:

51

answers:

1

Is there a way to let the user stop the execution of a sql query in python if it takes some long time? I am thinking of using a progress bar with a cancel button, but I wonder if there is a way to stop it in a clean way instead of killing abruptly the associated thread? (I am using both pysqlite2 and MySQLdb packages)

+3  A: 

hi, the only solution i see is to get the process id:

SHOW PROCESSLIST;

and kill it:

KILL <thread_id>;

i would execute those commands with mysqldb.

However, you should be carefull about the rollback. See for example: http://stackoverflow.com/questions/161960/sql-server-query-question-if-i-stop-a-long-running-query-does-it-rollback

hope it helps

Mermoz
Is this considered a "clean" way to terminate a query?
banx