Handling database connections in a saner way