templating and db query code example that works