Moved mysql functions to module