Update sqlite queries so they actually work with sqlite