Added basic DB writing functionality