Separated the database connection

Honestly I am a little unsure if I have done this correctly, lets find
out :)