Flask works but doesn't access database