def get_departments(schools):
"""
Retrieves a sorted list of all the departments.
:param schools: the list of schools to list the departments for.
:type schools: list
:return: the list of departments
:rtype: list
"""
sql = """
select distinct(owning_department_clevel)
from %s
where owning_school_clevel in ('%s')
order by owning_department_clevel
""" % (GradeResults._meta.db_table, "','".join(schools))
cursor = connection.cursor()
cursor.execute(sql)
result = []
for row in cursor.fetchall():
result.append(row[0])
return result
评论列表
文章目录