import telebot
import sqlite3
conn = sqlite3.connect('adcadczscbd.sqlite3', check_same_thread=False)
cursor = conn.cursor()
bot = telebot.TeleBot("")
@bot.message_handler(commands=['register'])
def get_text_messages(message):
usernam = message.from_user.username
data = cursor.execute(f"SELECT * FROM users WHERE usernames = {usernam}").fetchone()
if data is None:
username = [message.from_user.username]
cursor.execute("INSERT INTO users VALUES (?)", username)
conn.commit()
bot.reply_to(message, 'Поздравляю! Ты зарегистрировался')
else:
bot.reply_to(message, 'Ты уже зарегистрирован')
bot.infinity_polling(none_stop=True, timeout=0)
Вот вывод:
2022-11-23 09:22:02,205 (__init__.py:964 MainThread) ERROR - TeleBot: "Infinity polling exception: no such column: kwarsk"
2022-11-23 09:22:02,208 (__init__.py:966 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\__init__.py", line 959, in infinity_polling
self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\__init__.py", line 1047, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\__init__.py", line 1122, in __threaded_polling
raise e
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\__init__.py", line 1078, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\util.py", line 154, in raise_exceptions
raise self.exception_info
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\util.py", line 98, in run
task(*args, **kwargs)
File "C:\Users\limba\AppData\Roaming\Python\Python310\site-packages\telebot\__init__.py", line 6086, in _run_middlewares_and_handler
result = handler['function'](message)
File "E:\Bot\adcadczsc.py", line 10, in get_text_messages
data = cursor.execute(f"SELECT * FROM users WHERE usernames = {usernam}").fetchone()
sqlite3.OperationalError: no such column: