Small sql flush fix

SQL flushing takes quite a long time, and because before it was not
being committed until every statement was parsed and added, another
flush thread could have already started, leading to duplicate key/values
pairs.

Now fixed by committing after every statement is added.