grr/server/grr_response_server/databases/mysql_clients.py
def AddClientKeywords(self, client_id, keywords, cursor=None):
    """Associates the provided keywords with the client."""
    cid = mysql_utils.ClientIDToInt(client_id)
    now = datetime.datetime.utcnow()
    keywords = set(keywords)
    args = [(cid, mysql_utils.Hash(kw), kw, now) for kw in keywords]
    args = list(itertools.chain.from_iterable(args))  # Flatten.

    query = """
        INSERT INTO client_keywords
            (client_id, keyword_hash, keyword, timestamp)
        VALUES {}
        ON DUPLICATE KEY UPDATE timestamp = VALUES(timestamp)
            """.format(", ".join(["(%s, %s, %s, %s)"] * len(keywords)))
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
Associates the provided keywords with the client.
Associates the provided keywords with the client.
Associates the provided keywords with the client .
def AddClientKeywords(self, client_id, keywords, cursor=None):
    cid = mysql_utils.ClientIDToInt(client_id)
    now = datetime.datetime.utcnow()
    keywords = set(keywords)
    args = [(cid, mysql_utils.Hash(kw), kw, now) for kw in keywords]
    args = list(itertools.chain.from_iterable(args))  
    query = """
        INSERT INTO client_keywords
            (client_id, keyword_hash, keyword, timestamp)
        VALUES {}
        ON DUPLICATE KEY UPDATE timestamp = VALUES(timestamp)
            """.format(", ".join(["(%s, %s, %s, %s)"] * len(keywords)))
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
def AddClientKeywords ( self , client_id , keywords , cursor = None ) : cid = mysql_utils . ClientIDToInt ( client_id ) now = datetime . datetime . utcnow ( ) keywords = set ( keywords ) args = [ ( cid , mysql_utils . Hash ( kw ) , kw , now ) for kw in keywords ] args = list ( itertools . chain . from_iterable ( args ) ) query = """
        INSERT INTO client_keywords
            (client_id, keyword_hash, keyword, timestamp)
        VALUES {}
        ON DUPLICATE KEY UPDATE timestamp = VALUES(timestamp)
            """ . format ( ", " . join ( [ "(%s, %s, %s, %s)" ] * len ( keywords ) ) ) try : cursor . execute ( query , args ) except MySQLdb . IntegrityError as e : raise db . UnknownClientError ( client_id , cause = e )
Associates the provided keywords with the client.
Associates the provided keywords with the client .
"""Associates the provided keywords with the client.""" # Flatten.
self
client_id
keywords
cursor