Save the last used SQL query.

In case of disconnect or if we need to change databases first we
save the last query executed so that we may retry it again.