More Database interactions

Genericised various interactions so that fixes can be made quickly and
universally if needed. Now approximately capable of writing and parsing
datetimes and sessionIDs.