OperationalError('near "?": syntax error')
Мне нужно поместить в столбец значение "1" при этом имя столбца хранится в переменной "link_for_channel" поэтому я делаю всё через знак вопроса. Но у меня вылазит ошибка.
База Данных:
def Add_StatusSubscription(self, link_for_channel):
with self.conn:
return self.cursor.execute("INSERT INTO 'DataBase' (?) VALUES (1)", (link_for_channel,))
Основной код:
balance = 0
num = 0
people = 0
rand = 0
i = 3
def check_sub_channel(chat_member):
print(chat_member.status)
if chat_member.status != 'left':
return True
else:
return False
def Menu(message: types.Message):
global num
global rand
global i
if message.chat.type == 'private':
rand = random.randint(10, 25)
markup_Inline = types.InlineKeyboardMarkup(row_width=1) # Активация клавиатуры
Inline_B1 = types.InlineKeyboardButton(text="↗️Перейти в канал", url=channels_URL[i]) # добавление кнопки с именем
Inline_B2 = types.InlineKeyboardButton(text="✅Я выполнил!", callback_data="SUB_CHECK") # добавление кнопки с именем
markup_Inline.add(Inline_B1, Inline_B2)
bot.send_message(message.chat.id,f"⭐️<b>Доступно новое задание на {rand}₽:</b>\n\n?Перейди в канал, подпишись, возвращайся сюда и жми кнопку 'Я выполнил'?", parse_mode='HTML', reply_markup=markup_Inline)
else:
bot.send_message(message.from_user.id,MISTAKE)
@bot.message_handler(commands=["start"])
def menu_check(message: types.Message):
global people
global channels_URL
if message.chat.type == 'private':
get_column_names=conn.execute("select * from PandaDataBase limit 1")
channels_URL=[i[0] for i in get_column_names.description] # получение всех имён всех столбцов
@bot.message_handler(content_types=["text"])
def Reply_buttons(message):
if message.text == '?Задание':
Menu(message)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
global balance
global rand
global i
USER_ID = call.from_user.id
try:
if call.message:
if call.data=="SUB_CHECK":
print("1")
if check_sub_channel(bot.get_chat_member(chat_id=call.message.chat.id, user_id=USER_ID)):
bot.edit_message_text(text=TRY_SUB_MESSAGE, chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=markup_Inline_Next_Task)
db.Add_StatusSubscription(link_for_channel=channels_URL[i]) # Вот заветная строка
balance += rand
i += 1
########################### ЗАПУСК БОТА ################################
if __name__ == '__main__':
bot.infinity_polling()
