Sample code for querying database