diff options
Diffstat (limited to 'gn3/case_attributes.py')
-rw-r--r-- | gn3/case_attributes.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gn3/case_attributes.py b/gn3/case_attributes.py new file mode 100644 index 0000000..590052a --- /dev/null +++ b/gn3/case_attributes.py @@ -0,0 +1,17 @@ +"""Implement case-attribute manipulations.""" +from MySQLdb.cursors import DictCursor +from flask import jsonify, Response, Blueprint, current_app + +from gn3.db_utils import database_connection + +caseattr = Blueprint("case-attribute", __name__) + +@caseattr.route("/<int:inbredset_id>", methods=["GET"]) +def inbredset_case_attributes(inbredset_id: int) -> Response: + """Retrieve ALL case-attributes for a specific InbredSet group.""" + with (database_connection(current_app.config["SQL_URI"]) as conn, + conn.cursor(cursorclass=DictCursor) as cursor): + cursor.execute( + "SELECT * FROM CaseAttribute WHERE InbredSetId=%(inbredset_id)s", + {"inbredset_id": inbredset_id}) + return jsonify(tuple(dict(row) for row in cursor.fetchall())) |