centralize the sql connection stuff. this passes a simpletest as well.