def commit_exists(cursor, sha):
  """Returns whether at least one commit with a given exists in the database."""
  cursor.execute('SELECT COUNT(*) FROM commit WHERE sha = %s', sha)
  return cursor.fetchone()[0] > 0