From ea7944b5f5e536c3ad0829dff674f91ba25b548e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 3 Sep 2024 11:27:51 -0500 Subject: Update species queries * Use the more reliable 'Species.Id' field * Provide more of a species' details --- uploader/species/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'uploader') diff --git a/uploader/species/models.py b/uploader/species/models.py index bde38ce..481f8be 100644 --- a/uploader/species/models.py +++ b/uploader/species/models.py @@ -8,8 +8,8 @@ def all_species(conn: mdb.Connection) -> tuple: "Retrieve the species from the database." with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - "SELECT SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName, " - "FullName, TaxonomyId FROM Species") + "SELECT Id AS SpeciesId, SpeciesName, LOWER(Name) AS Name, " + "MenuName, FullName, TaxonomyId FROM Species") return tuple(cursor.fetchall()) return tuple() @@ -18,8 +18,9 @@ def species_by_id(conn: mdb.Connection, speciesid) -> dict: "Retrieve the species from the database by id." with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( - "SELECT SpeciesId, SpeciesName, LOWER(Name) AS Name, MenuName, " - "FullName FROM Species WHERE SpeciesId=%s", + "SELECT Id AS SpeciesId, SpeciesName, LOWER(Name) AS Name, " + "MenuName, FullName, TaxonomyId, Family, FamilyOrderId, OrderId " + "FROM Species WHERE SpeciesId=%s", (speciesid,)) return cursor.fetchone() -- cgit v1.2.3