aboutsummaryrefslogtreecommitdiff
path: root/uploader/db/species.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/db/species.py')
-rw-r--r--uploader/db/species.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/uploader/db/species.py b/uploader/db/species.py
new file mode 100644
index 0000000..653e59b
--- /dev/null
+++ b/uploader/db/species.py
@@ -0,0 +1,22 @@
+"""Database functions for species."""
+import MySQLdb as mdb
+from MySQLdb.cursors import DictCursor
+
+def 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 FROM Species")
+ return tuple(cursor.fetchall())
+
+ return tuple()
+
+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",
+ (speciesid,))
+ return cursor.fetchone()