再上篇中撷取到的讯息只会即时传到聊天室,并不会保存下来。要保存讯息的话,就要把讯息保存到资料库。
这边设计资料表讯息与LINE emoji存放的资料表,message_emoji的mid为FK关联到group_buying_message的mid
group_buying_message
mid | keyword | message_text |
---|
message_emoji
eid | mid | index | product_id | emoji_id |
---|
mid为FK关联到group_buying_message的mid
def update_emoji_message(text,keyword,emojis):
cursor = conn.cursor()
cursor.execute("INSERT INTO group_buying_message (message_text, keyword) VALUES (%s, %s);", (text, keyword))
cursor.execute(f"SELECT mid FROM group_buying_message WHERE message_text='{text}';")
row = cursor.fetchone()
for emoji in emojis:
cursor.execute("INSERT INTO message_emoji (mid, index, product_id, emoji_id) VALUES (%s, %s, %s, %s);", (row, emoji.index, emoji.product_id, emoji.emoji_id))
conn.commit()
cursor.close()
print("successfully update emoji message")
<<: Unity与Photon的新手相遇旅途 | Day13-攻击优化
>>: Stream Processing (1-1) - Transmitting Event Streams
简单介绍一下变数在JS中的几个性质,之後的篇章会比较深入的讲解,这些性质背後的原因们 看变数的值,决...
今天来介绍Odoo studio,对於程序苦手或非程序人员,运用Odoo studio可以直接透过见...
在昨天介绍了vue-router,我们知道vue-router就是扮演一个网址提供者的脚色,让每个画...
阵列操作介绍 (下篇) 介绍四种阵列运用: map filter find findlndex 3....
部署及开启API服务-flask 导入套件 import base64 import datetim...