def WriteClientStats(self,
                       client_id,
                       stats,
                       cursor=None):
    """Stores a ClientStats instance."""

    try:
      cursor.execute(
          """
          INSERT INTO client_stats (client_id, payload, timestamp)
          VALUES (%s, %s, FROM_UNIXTIME(%s))
          ON DUPLICATE KEY UPDATE payload=VALUES(payload)
          """, [
              db_utils.ClientIDToInt(client_id),
              stats.SerializeToString(),
              mysql_utils.RDFDatetimeToTimestamp(rdfvalue.RDFDatetime.Now())
          ])
    except MySQLdb.IntegrityError as e:
      if e.args[0] == mysql_error_constants.NO_REFERENCED_ROW_2:
        raise db.UnknownClientError(client_id, cause=e)
      else:
        raise
def WriteClientStats ( self , client_id , stats , cursor = None ) : try : cursor . execute ( """
          INSERT INTO client_stats (client_id, payload, timestamp)
          VALUES (%s, %s, FROM_UNIXTIME(%s))
          ON DUPLICATE KEY UPDATE payload=VALUES(payload)
          """ , [ db_utils . ClientIDToInt ( client_id ) , stats . SerializeToString ( ) , mysql_utils . RDFDatetimeToTimestamp ( rdfvalue . RDFDatetime . Now ( ) ) ] ) except MySQLdb . IntegrityError as e : if e . args [ 0 ] == mysql_error_constants . NO_REFERENCED_ROW_2 : raise db . UnknownClientError ( client_id , cause = e ) else : raise
Stores a ClientStats instance.