Skip to content

Commit

Permalink
#49: Allow insertion of multiple rows
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 30, 2019
1 parent 0be6159 commit f752db5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ def create_row_from_json(table, data):
create_query.execute_query()
return create_query.inserted_row.to_dict()

def create_rows_from_json(table, data):
"""
Given a List containing dictionary representations of entities, or a dictionary representation of an entity, insert
the entities into the table and return the created entities
:param table: The table to insert the entities in
:param data: The entities to be inserted
:return: The inserted entities
"""
if type(data) is list:
return [create_row_from_json(table, entity) for entity in data]
return create_row_from_json(table, data)

def get_row_by_id(table, id):
"""
Expand Down

0 comments on commit f752db5

Please sign in to comment.