changed sqlite query from INSERT to UPDATE (squlite has no 'ON DUPLICATE KEY')