Insert_the_logic_two
2020-05-13 本文已影响0人
月夜星空下
import time
import pymysql
import mysql.connector
from plan2 import The_original_title, all_one_middle, td
# td = input("请输入栏目编号(1-4):")
i = 0
for tit, cet in zip(The_original_title, all_one_middle):
i += 1
print(tit, cet)
link = pymysql.Connect(host='localhost', port=3306, user='root', password='yz1028959', db='dede', charset='utf8')
cursor = link.cursor()
print("~~~连接正常~~~", i)
data = (td, cet)
tdtt = (td, tit)
sql = 'INSERT INTO dede_addonarticle(typeid, body) VALUES (%s,%s)'
addonarticle = cursor.execute(sql, data, )
# print('1')
sql = 'INSERT INTO dede_archives(typeid, ismake, channel, title, mid, voteid, dutyadmin) VALUES(%s, 1, 1,%s, 1, 0, 1)'
archives = cursor.execute(sql, tdtt, )
# archives = cursor.execute(sql)
# print('2')
sql = 'INSERT INTO dede_arctiny(typeid, channel, mid) VALUES (%s, 1, 1)' % td
arctiny = cursor.execute(sql)
# print('3')
cursor.close()
link.close()
print("~成功执行~", i)
print("sucessfully!")