Revert "Revert "Final Database access code""

This reverts commit b649f987361856ec66e67273a1c059c7f9056826.