<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_record(cls, id_, with_deleted=False):
 """Retrieve the record by id. Raise a database exception if the record does not exist. :param id_: record ID. :param with_deleted: If `True` then it includes deleted records. :returns: The :class:`Record` instance. """

        with db.session.no_autoflush:
            query = RecordMetadata.query.filter_by(id=id_)
            if not with_deleted:
                query = query.filter(RecordMetadata.json != None)  # noqa
            obj = query.one()
            return cls(obj.json, model=obj)