def insert_link(self, source_article_id, target_article_name, data, position, zip_file_path):
target_article_id = self.db_build_view._resolve_title(target_article_name.split('-----##$$$##-----')[0].replace('_', ' '))
data['target_article_name'] = target_article_name.split('-----##$$$##-----')[0].replace('_', ' ')
data['source_article_id'] = source_article_id
data['target_article_id'] = target_article_id
if position is not None:
data['target_x_coord_1920_1080'] = position[0]
data['target_y_coord_1920_1080'] = position[1]
if data['target_y_coord_1920_1080'] < 0:
data['target_y_coord_1920_1080'] = 0
else:
data['target_x_coord_1920_1080'] = None
data['target_y_coord_1920_1080'] = None
#print data
sql = "INSERT INTO redirects_candidates (source_article_id, target_article_id, target_article_name," \
"target_position_in_text, target_position_in_text_only, target_position_in_section, " \
"target_position_in_section_in_text_only, section_name," \
" section_number, target_position_in_table, table_number, table_css_class, table_css_style," \
" target_x_coord_1920_1080, target_y_coord_1920_1080) VALUES" \
"(%(source_article_id)s, %(target_article_id)s, %(target_article_name)s, %(target_position_in_text)s," \
"%(target_position_in_text_only)s, %(target_position_in_section)s, %(target_position_in_section_in_text_only)s, " \
"%(section_name)s, %(section_number)s, %(target_position_in_table)s, %(table_number)s, " \
"%(table_css_class)s, %(table_css_style)s," \
"%(target_x_coord_1920_1080)s, %(target_y_coord_1920_1080)s);"
try:
self.cursor.execute(sql, data)
#logging.info('DB Insert Success for target article id: "%s" ' % target_article_id)
except (MySQLdb.Error, MySQLdb.Warning), e:
#print sql
print ('FAIL: Data caused warning or error "%s" for target_article_id: "%s" in for source_article_id: "%s"', data, target_article_id, source_article_id)
print 'FAIL: EXCEPTION:', e
print zip_file_path
#print('DB Insert Error target article id: "%s" ' % target_article_id)
return target_article_id
redirectscandidatespostioninserter.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录