那是我的第一个 python sql,我试图编写这个机器人我得到了这个错误:
SQL 代码
import sqlite3
...
@commands.Cog.listener()
async def on_message(self, message):
db = sqlite3.connect('banco.sqlite')
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()
错误:
File "/Users/CIP/Documents/GitHub/economia/cogs/dinheiro.py", line 54, in on_message
cursor.execute(f'SELECT column1 FROM banco WHERE column1 = "{message.author.id}"')
sqlite3.OperationalError: no such table: banco
第 54 行
cursor.execute(f'SELECT nome FROM banco WHERE nome = "{message.author.id}"')