我很難用MySQLdb模塊將信息插入到我的數據庫中。我需要在表格中插入2個變量。我的表格是用戶標識,user_id的類型是varchar,計數類型是int。Python MySQL插入參數
SQL = 'select user_id,count(*)AS num from client1 group by user_id order by count(*) desc;'
for row in cursor.execute(SQL):
a = row.user_id
b = row.num
cursormysql.execute("insert into userid(user_id,count) VALUES (%s,%s))",(a,b))
db.commit()
請編輯您的問題,包括你的代碼和錯誤文本,而不是圖像。想象一下,能夠幫助你的一個人非常忙碌,不會爲等待圖像加載來回答問題而煩惱。 –
@Wai Ha Lee,謝謝 – tanxin