字典是
keywords_dict{}
{'茉莉花茶泡多久': 10, '苦丁长什么样子图片': 5, '茶叶茶加上蜂糖能喝吗': 1, '古丈毛尖多少钱一斤': 29, '干玫瑰花过期': 1}
I am using the database linked to pymysql
The previous statistical data was a single line, so use this
cur.execute('insert into pctongji(yesterday_str, item, question, topic, people, celebrity, brand, category, article) values(%s,%s,%s,%s,%s,%s,%s,%s,%s)', (yesterday_str, category_dict['item'], category_dict['question'], category_dict['topic'], category_dict['people'], category_dict['celebrity'], category_dict['brand'], category_dict['category'], category_dict['article']))
Now is how to save multiple rows into the database.
The database has two fields, namely keywords and count, which correspond to the contents in the dictionary above.
How to write the sql statement? What do you want? Deposit as number of days
Make enough food and clothing by yourself
It is recommended to use executemany