Factorise SqlQuery, add database CRUD template