def persist_questions(self, question_list_per_topic): insert_sql = "INSERT IGNORE INTO ZHIHU_QUESTION " \ "(QUESTION_ID, QUESTION_TITLE, ANSWER, IS_TOP_QUESTION, CREATED_TIME) " \ "VALUES (%s, %s, %s, %s, %s)" tm = TransactionManager() tm.execute_many_sql(insert_sql, question_list_per_topic) tm.close_connection()
def persist_topics(topic_list): """ Persist topics into mysql :param topic_list: all the topics including level 1 and level 2. :return: None """ insert_sql = "INSERT IGNORE INTO ZHIHU_TOPIC (TOPIC_ID, NAME, PARENT_ID) \ VALUES (%s, %s, %s)" print "insert sql:%s" % insert_sql tm = TransactionManager() tm.execute_many_sql(insert_sql, topic_list) tm.close_connection()