From c2ef963c2f0f8a4c9428d48abed1094ff0441935 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 10 May 2021 21:07:32 +0300 Subject: db: species: Add method for fetching all species --- gn3/db/species.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gn3/db/species.py b/gn3/db/species.py index 91b78e2..0deae4e 100644 --- a/gn3/db/species.py +++ b/gn3/db/species.py @@ -6,6 +6,14 @@ from typing import Any, Optional, Tuple from MySQLdb import escape_string +def get_all_species(conn: Any) -> Optional[Tuple]: + """Return a list of all species""" + with conn.cursor() as cursor: + cursor.execute("SELECT Name, MenuName FROM Species " + "ORDER BY OrderId") + return cursor.fetchall() + + def get_chromosome(name: str, is_species: bool, conn: Any) -> Optional[Tuple]: """Given either a group or a species Name, return all the species""" _sql = ("SELECT Chr_Length.Name, Chr_Length.OrderId, " -- cgit v1.2.3