#765: Fix some bugs in SQLite database layer. Patch by Koos.
#765: Clean up query whitespace in MySQL drivers. Patch by Koos.