docs: def WriteFlowObject(self, flow_obj, cursor=None):
      """Writes a flow object to the database."""
  
      query = """
      INSERT INTO flows (client_id, flow_id, long_flow_id, parent_flow_id,
                         parent_hunt_id, flow, flow_state,
                         next_request_to_process, pending_termination, timestamp,
                         network_bytes_sent, user_cpu_time_used_micros,
                         system_cpu_time_used_micros, num_replies_sent, last_update)
      VALUES (%(client_id)s, %(flow_id)s, %(long_flow_id)s, %(parent_flow_id)s,
              %(parent_hunt_id)s, %(flow)s, %(flow_state)s,
              %(next_request_to_process)s, %(pending_termination)s,
              FROM_UNIXTIME(%(timestamp)s),
              %(network_bytes_sent)s, %(user_cpu_time_used_micros)s,
              %(system_cpu_time_used_micros)s, %(num_replies_sent)s, NOW(6))
      ON DUPLICATE KEY UPDATE
          flow=VALUES(flow),
          flow_state=VALUES(flow_state),
          next_request_to_process=VALUES(next_request_to_process),
          last_update=VALUES(last_update)
      """
  
      user_cpu_time_used_micros = db_utils.SecondsToMicros(
          flow_obj.cpu_time_used.user_cpu_time)
      system_cpu_time_used_micros = db_utils.SecondsToMicros(
          flow_obj.cpu_time_used.system_cpu_time)
  
      args = {
          "client_id": db_utils.ClientIDToInt(flow_obj.client_id),
          "flow_id": db_utils.FlowIDToInt(flow_obj.flow_id),
          "long_flow_id": flow_obj.long_flow_id,
          "flow": flow_obj.SerializeToString(),
          "flow_state": int(flow_obj.flow_state),
          "next_request_to_process": flow_obj.next_request_to_process,
          "timestamp": mysql_utils.RDFDatetimeToTimestamp(flow_obj.create_time),
          "network_bytes_sent": flow_obj.network_bytes_sent,
          "num_replies_sent": flow_obj.num_replies_sent,
          "user_cpu_time_used_micros": user_cpu_time_used_micros,
          "system_cpu_time_used_micros": system_cpu_time_used_micros,
      }
  
      if flow_obj.parent_flow_id:
        args["parent_flow_id"] = db_utils.FlowIDToInt(flow_obj.parent_flow_id)
      else:
        args["parent_flow_id"] = None
  
      if flow_obj.parent_hunt_id:
        args["parent_hunt_id"] = db_utils.HuntIDToInt(flow_obj.parent_hunt_id)
      else:
        args["parent_hunt_id"] = None
  
      if flow_obj.HasField("pending_termination"):
        serialized_termination = flow_obj.pending_termination.SerializeToString()
        args["pending_termination"] = serialized_termination
      else:
        args["pending_termination"] = None
  
      try:
        cursor.execute(query, args)
      except MySQLdb.IntegrityError as e:
        raise db.UnknownClientError(flow_obj.client_id, cause=e)