def insert(self, events):
if not len(events):<EOL><INDENT>return<EOL><DEDENT>keys = sorted(events[<NUM_LIT:0>].keys())<EOL>ss = '<STR_LIT:U+002C>'.join(['<STR_LIT:%s>' for _ in keys])<EOL>query = '<STR_LIT>' % (self.table, '<STR_LIT:U+002C>'.join(keys))<EOL>data = []<EOL>for event in events:<EOL><INDENT>query += '<STR_LIT>' % ss<EOL>data += [event[k] for k in keys]<EOL><DEDENT>query = query[:-<NUM_LIT:1>] + '<STR_LIT:;>'<EOL>LOG.info("<STR_LIT>", query, data)<EOL>conn = self.conn.conn<EOL>cursor = conn.cursor()<EOL>cursor.execute(query, data)<EOL>conn.commit()<EOL>
Constructs and executes a MySQL insert for the given events.