Implementation db connection. Finished, ready for testing and fine
tuning.