Implements getShift. Changes to connect to DB only once.