Move all mysql specific code into db.c
Fix memory leak
Fix talloc leaks
Fix reconnects in mysql wrapper