为什么我的sqlite数据库表即使有表也给我这个错误?
代码
@commands.Cog.listener()
async def on_message(self, message):
db = sqlite3.connect('banco.db')
cursor = db.cursor()
cursor.execute(f'SELECT nome FROM banco WHERE nome = "{message.author.id}"')
result = cursor.fetchone()
if result is None:
sql = ('INSERT INTO banco(nome, dinheiro) VALUES(?, ?)')
val = (message.author.id, 0)
cursor.execute(sql, val)
db.comit()
cursor.close()
错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "/Users/CIP/Documents/GitHub/economia/cogs/dinheiro.py", line 56, in on_message
cursor.execute(f'SELECT nome FROM banco WHERE nome = "{message.author.id}"')
sqlite3.OperationalError: no such table: banco
LINE
cursor.execute(f'SELECT nome FROM banco WHERE nome = "{message.author.id}"')