The documentation for the QSqlQuery constructor says "If query is not an empty string, it will be executed.", which means that when you call exec() you are executing it twice.