grr/server/grr_response_server/databases/mysql_flows.py
def _WriteResponses(self, responses, timestamp_str, cursor):
    """Builds the writes to store the given responses in the db."""

    query = ("INSERT IGNORE INTO flow_responses "
             "(client_id, flow_id, request_id, response_id, "
             "response, status, iterator, timestamp) VALUES ")

    templates = []
    args = []
    for r in responses:
      templates.append("(%s, %s, %s, %s, %s, %s, %s, %s)")
      client_id_int = mysql_utils.ClientIDToInt(r.client_id)
      flow_id_int = mysql_utils.FlowIDToInt(r.flow_id)

      args.append(client_id_int)
      args.append(flow_id_int)
      args.append(r.request_id)
      args.append(r.response_id)
      if isinstance(r, rdf_flow_objects.FlowResponse):
        args.append(r.SerializeToString())
        args.append("")
        args.append("")
      elif isinstance(r, rdf_flow_objects.FlowStatus):
        args.append("")
        args.append(r.SerializeToString())
        args.append("")
      elif isinstance(r, rdf_flow_objects.FlowIterator):
        args.append("")
        args.append("")
        args.append(r.SerializeToString())
      else:
        # This can't really happen due to db api type checking.
        raise ValueError("Got unexpected response type: %s %s" % (type(r), r))
      args.append(timestamp_str)

    query += ",".join(templates)
    cursor.execute(query, args)
Builds the writes to store the given responses in the db.
Builds the writes to store the given responses in the db.
Builds the writes to store the given responses in the db .
def _WriteResponses(self, responses, timestamp_str, cursor):
    query = ("INSERT IGNORE INTO flow_responses "
             "(client_id, flow_id, request_id, response_id, "
             "response, status, iterator, timestamp) VALUES ")
    templates = []
    args = []
    for r in responses:
      templates.append("(%s, %s, %s, %s, %s, %s, %s, %s)")
      client_id_int = mysql_utils.ClientIDToInt(r.client_id)
      flow_id_int = mysql_utils.FlowIDToInt(r.flow_id)
      args.append(client_id_int)
      args.append(flow_id_int)
      args.append(r.request_id)
      args.append(r.response_id)
      if isinstance(r, rdf_flow_objects.FlowResponse):
        args.append(r.SerializeToString())
        args.append("")
        args.append("")
      elif isinstance(r, rdf_flow_objects.FlowStatus):
        args.append("")
        args.append(r.SerializeToString())
        args.append("")
      elif isinstance(r, rdf_flow_objects.FlowIterator):
        args.append("")
        args.append("")
        args.append(r.SerializeToString())
      else:
        raise ValueError("Got unexpected response type: %s %s" % (type(r), r))
      args.append(timestamp_str)
    query += ",".join(templates)
    cursor.execute(query, args)
def _WriteResponses ( self , responses , timestamp_str , cursor ) : query = ( "INSERT IGNORE INTO flow_responses " "(client_id, flow_id, request_id, response_id, " "response, status, iterator, timestamp) VALUES " ) templates = [ ] args = [ ] for r in responses : templates . append ( "(%s, %s, %s, %s, %s, %s, %s, %s)" ) client_id_int = mysql_utils . ClientIDToInt ( r . client_id ) flow_id_int = mysql_utils . FlowIDToInt ( r . flow_id ) args . append ( client_id_int ) args . append ( flow_id_int ) args . append ( r . request_id ) args . append ( r . response_id ) if isinstance ( r , rdf_flow_objects . FlowResponse ) : args . append ( r . SerializeToString ( ) ) args . append ( "" ) args . append ( "" ) elif isinstance ( r , rdf_flow_objects . FlowStatus ) : args . append ( "" ) args . append ( r . SerializeToString ( ) ) args . append ( "" ) elif isinstance ( r , rdf_flow_objects . FlowIterator ) : args . append ( "" ) args . append ( "" ) args . append ( r . SerializeToString ( ) ) else : raise ValueError ( "Got unexpected response type: %s %s" % ( type ( r ) , r ) ) args . append ( timestamp_str ) query += "," . join ( templates ) cursor . execute ( query , args )
Builds the writes to store the given responses in the db.
Builds the writes to store the given responses in the db .
"""Builds the writes to store the given responses in the db.""" # This can't really happen due to db api type checking.
self
responses
timestamp_str
cursor