Convert tabs to spaces

Converted the tabs to spaces in datfile.py
Tidy database manager

Tidied up the database manager. This involved fixing the SQL file and
creating a singleton class that we can use as a decorator.
Tidy up datfile.py

Tidied up the datfile.py and cleared a few bugs hear and there.