Skip to content

Commit

Permalink
Update get_row_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jul 29, 2019
1 parent 60b3c98 commit 630f683
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,10 @@ def get_row_by_id(table, id):
:return: the record retrieved
"""
log.info(f" Querying {table.__tablename__} for record with ID: {id}")
session = get_icat_db_session()
result = session.query(table).filter(table.ID == id).first()
if result is not None:
log.info(" Record found, closing DB session")
session.close()
return result
session.close()
raise MissingRecordError(f" Could not find record in {table.__tablename__} with ID: {id}")
read_query = ReadQuery(table)
where_filter = WhereFilter("ID", id)
where_filter.apply_filter(read_query)
return read_query.get_single_result()


def delete_row_by_id(table, id):
Expand Down

0 comments on commit 630f683

Please sign in to comment.