discord py SQLite 警告命令 db 错误
Posted
技术标签:
【中文标题】discord py SQLite 警告命令 db 错误【英文标题】:discord py SQLite warning command db error 【发布时间】:2021-09-06 03:01:41 【问题描述】:async def warnings(ctx,*,arg1):
#await ctx.send('Warning \nreason '.format(arg1))
print(arg1)
name=arg1
db.execute('SELECT name FROM warnings WHERE name = "?"', (name))
conn.commit()
warnings = db.fetchall()
print(warnings)
我试图在 sqlite 中为用户的警告进行搜索。但我有这个错误,我该如何解决这个问题 我做错了什么?
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "d:/_User/Desktop/Development/shop.py", line 279, in warnings
db.execute('SELECT name FROM warnings WHERE name = "?"', "name")
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 6 supplied.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Python38\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 6 supplied.
【问题讨论】:
【参考方案1】:First result on Google 是另一个回答您问题的 SO 帖子。您需要通过在末尾添加逗号来使参数成为元组而不是字符串。
(name,)
在询问之前尽量自己研究问题,这不应该超过 5 秒。
【讨论】:
以上是关于discord py SQLite 警告命令 db 错误的主要内容,如果未能解决你的问题,请参考以下文章
如何在 discord.py 中使用 sqlite3 配置欢迎事件?
尝试使用 sqlite3 向我的 discord.py 机器人添加自定义前缀