Reads all cronjobs from the database.

def ReadCronJobs(self, cronjob_ids=None, cursor=None):
    """Reads all cronjobs from the database."""
    query = ("SELECT job, UNIX_TIMESTAMP(create_time), enabled, "
             "forced_run_requested, last_run_status, "
             "UNIX_TIMESTAMP(last_run_time), current_run_id, state, "
             "UNIX_TIMESTAMP(leased_until), leased_by "
             "FROM cron_jobs")
    if cronjob_ids is None:
      cursor.execute(query)
      return [self._CronJobFromRow(row) for row in cursor.fetchall()]

    query += " WHERE job_id IN (%s)" % ", ".join(["%s"] * len(cronjob_ids))
    cursor.execute(query, cronjob_ids)
    res = []
    for row in cursor.fetchall():
      res.append(self._CronJobFromRow(row))

    if len(res) != len(cronjob_ids):
      missing = set(cronjob_ids) - set([c.cron_job_id for c in res])
      raise db.UnknownCronJobError("CronJob(s) with id(s) %s not found." %
                                   missing)
    return res