Constructing queries for the sqlite library.