Refactor api to explicitly close mysql connections

@WayneKoorts @markstuart 
On @andrewm-mediasuite's advice, I have refactored a bit to explicitly open use and then close mysql connections. This is because due to nodes long running process nature and mysql's want to close inactive connections after a while (which crashes the node process) the app was crashing on staging every couple mins.
Please give it a once over.
I was thinking it might be good to somehow abstract the db connection stuff into an object that has both connect and close methods or some such