<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def flush(self, safe=None):
		''' Perform all database operations currently in the queue'''
		result = None
		for index, op in enumerate(self.queue):
			try:
				result = op.execute()
			except:
				self.clear_queue()
				self.clear_cache()
				raise
		self.clear_queue()
		return result