'Raises exception if more than 20,000 `INSERT`, `UPDATE` queries are
executed in one transaction. This is to ensure that writes are always flushed otherwise this
could cause the system to hang.'

def check_transaction_status(self, query):

    if (self.transaction_writes and query and (query.strip().split()[0].lower() in [u'start', u'alter', u'drop', u'create', u'begin', u'truncate'])):
        raise Exception(u'This    statement    can    cause    implicit    commit')
    if (query and (query.strip().lower() in (u'commit', u'rollback'))):
        self.transaction_writes = 0
    if (query[:6].lower() in (u'update', u'insert', u'delete')):
        self.transaction_writes += 1
        if (self.transaction_writes > 200000):
            if self.auto_commit_on_many_writes:
                frappe.db.commit()
            else:
                frappe.throw(_(u'Too    many    writes    in    one    request.    Please    send    smaller    requests'), frappe.ValidationError)
