Updated database interface code to use Query object.

Signed-off-by: Nigel <Nigel@192.168.1.105>