def import_data(self, head, rows):
"""Imports data"""
self.connect()
self.cache = Cache()
cursor = self.conn.cursor()
sql = """INSERT INTO importactions (remote_addr, remote_user, sender_addr, sender_user, ia_when) VALUES (%s, %s, %s, %s, %s)"""
cursor.execute(sql, [
environ.get("REMOTE_ADDR", ""), environ.get("REMOTE_USER", ""),
head["sender_addr"],head["sender_user"],
datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
])
importactionid = cursor.lastrowid
for row in rows:
for key in self.column_table_mapping:
self.fill_id_cache(cursor, key, row, row[key])
for row in rows:
sql = """INSERT IGNORE INTO checkins(type, ci_when, whoid, repositoryid, dirid, fileid, revision, branchid, addedlines, removedlines, descid, stickytag, commitid, importactionid)
VALUE (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
cursor.execute(self.rewrite_sql(sql), [
row["type"],
row["ci_when"],
self.cache.get("who", row["who"]),
self.cache.get("repository", row["repository"]),
self.cache.get("dir", row["dir"]),
self.cache.get("file", row["file"]),
row["revision"],
self.cache.get("branch", row["branch"]),
row["addedlines"],
row["removedlines"],
self.cache.get("description", row["description"]),
"",
self.cache.get("hash", row["commitid"]),
str(importactionid)
])
cursor.close()
self.disconnect()
评论列表
文章目录