implement DB functions

Signed-off-by: Aleksey Snisar <saiuz2000@gmail.com>