SQlite version check needs to be applied for the function insert_reference_entity just like it exists for the function insert_assessment. The reason is that older versions of sqlite within python does not understand the RETURNING statement.
insert_reference_entity
insert_assessment
RETURNING
\approve @ds @laurens @shinde