import disnake
from disnake.ext import commands
import sqlite3 as sql
con = sql.connect('checking.db')
with con:
cur = con.cursor()
cur.execute(f"CREATE TABLE IF NOT EXISTS `checking` (`id` INTEGER, `tname` STRING, `dname` STRING)")
con1 = sql.connect('tournament.db')
with con1:
cur1 = con.cursor()
cur1.execute(f"CREATE TABLE IF NOT EXISTS `tournament` (`id` INTEGER, `tname` STRING, `dname` STRING)")
def check(tn, dn):
cur.execute("SELECT tname, dname FROM tournament WHERE id > 0")
i = cur.fetchall()
k = (tn, dn)
for num in range(len(i)):
if k != i[num]:
num += 1
elif k == i[num]:
exit()
def new_id():
cur.execute("SELECT id FROM tournament")
one_result = cur.fetchall()
dlina = len(one_result)
newid = dlina + 1
return newid
passed = None
bot = commands.Bot(command_prefix='!', help_command=None, intents=disnake.Intents.all())
@bot.event
async def on_ready():
print(f'Bot {bot.user} is ready to work!')
@bot.command()
async def register(ctx, arg):
cur.execute(f"SELECT tname FROM checking WHERE id = {arg}")
tname = cur.fetchone()
cur.execute(f"SELECT dname FROM checking WHERE id = {arg}")
dname = cur.fetchone()
my_id = new_id()
check(tname, dname)
cur1.execute(f"INSERT INTO `tournament` VALUES ('{my_id}','{tname}','{dname}')")
cur.execute(f"DELETE * FROM checking WHERE id = {arg}")
await ctx.send(f'Введеный тобой код подтверждения: {arg}'
f'Поздравляю с успешной регистрацией!')
Ошибка выводится такая:
Ignoring exception in command register:
Traceback (most recent call last):
File "C:\Users\Mark\PycharmProjects\pythonProject\venv\lib\site-packages\disnake\ext\commands\core.py", line 173, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Mark\PycharmProjects\pythonProject\dsbot.py", line 51, in register
cur1.execute(f"INSERT INTO `tournament` VALUES ('{my_id}','{tname}','{dname}')")
sqlite3.OperationalError: near "ANONIM_1648": syntax error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Mark\PycharmProjects\pythonProject\venv\lib\site-packages\disnake\ext\commands\bot_base.py", line 589, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Mark\PycharmProjects\pythonProject\venv\lib\site-packages\disnake\ext\commands\core.py", line 914, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Mark\PycharmProjects\pythonProject\venv\lib\site-packages\disnake\ext\commands\core.py", line 182, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: near "ANONIM_1648": syntax error