sqlite compatibility

Add the functions used here that sqlite lacks, so this also works for the sqlite3 engine. It works quick quickly for me.