Support for sqlite3

% should not be used for sql, replaced with ?
some sqlite syntax fixes