Python 参数错误:ValueError:';参数';arg(<;class';list';>;)只能是元组或字典

Python 参数错误:ValueError:';参数';arg(<;class';list';>;)只能是元组或字典,python,mysql,database,discord.py,pymssql,Python,Mysql,Database,Discord.py,Pymssql,我正在尝试将一些不协调的bot数据插入数据库。我使用了参数方法,但它不起作用。我不熟悉用python处理MYSQL 我的代码 @bot.event #Edit Log async def on_message_edit(before, after): MemberId = before.author.id await bot.send_message(bot.get_channel('480526097331650590'), 'The user <@%s> have

我正在尝试将一些不协调的bot数据插入数据库。我使用了参数方法,但它不起作用。我不熟悉用python处理MYSQL

我的代码

@bot.event
#Edit Log
async def on_message_edit(before, after):
    MemberId = before.author.id
    await bot.send_message(bot.get_channel('480526097331650590'), 'The user <@%s> have edited his message from ``' % (MemberId) + before.content + '`` to `` ' + after.content + ' `` ')


    #Connection to sql
    conn = pymssql.connect(server='HAMOOOOD25\DISCORDPY', user='sa', password='31045', database='ChatLogs')
    cursor = conn.cursor()

    #Declaring vars
    BeforeId = before.id
    BAuthId = before.author.id
    BAuthN = before.author.id
    Befcon = before.content
    Aftcon = after.content

    sql = "INSERT INTO Editedmsg VALUES (Message_ID, Message_Author_ID, Message_Owner_Name, Previous_Message, After_Message)"
    cursor.execute(sql, [(before.id), (before.author.id,), (before.author.id), (before.content), (after.content)])
    conn.close()
@bot.event
#编辑日志
消息编辑时的异步定义(之前、之后):
MemberId=before.author.id
wait bot.send_message(bot.get_channel('48052609731650590'),'用户已将其消息从“%”(MemberId)+before.content+`编辑到“`+after.content+`'))
#与sql的连接
conn=pymssql.connect(server='hamood25\DISCORDPY',user='sa',password='31045',database='ChatLogs')
游标=连接游标()
#声明变量
BeforeId=BeforeId.id之前
BAuthId=before.author.id
BAuthN=before.author.id
Befcon=before.content
Aftcon=after.content
sql=“插入Editedmsg值(消息\u ID、消息\u作者\u ID、消息\u所有者\u名称、前一条消息、后一条消息)”
执行(sql,[(before.id),(before.author.id),,(before.author.id),(before.content),(before.content),(before.content)])
康涅狄格州关闭
我的错误

ValueError: 'params' arg (<class 'list'>) can be only a tuple or a dictionary.
ValueError:'params'arg()只能是元组或字典。

显然,错误消息建议您使用
元组,而不是
列表
在你的电话里。除此之外,您的
sql
查询的格式不正确(请参见第节)。您的
execute
调用应该如下所示:

sql = "INSERT INTO Editedmsg VALUES (%d, %d, %d, %s, %s)"
params = (before.id, before.author.id, before.author.id, 
          before.content, after.content)
cursor.execute(sql, params)

@我不知道。您应该包含完整的错误消息(207,b“无效列名'MessageID'。您确定在消息编辑上的
中得到它吗?您是否有完整的回溯,而不仅仅是最后一行?我确定它在那里,因为我只在消息编辑上的
中使用它,在这种情况下,使用单元组:
(singleVar,)