Split db functions into separate module