Здравствуйте! Столкнулся с проблемой, при создании в базе данных юзера, почему то выдает ошибку:
Traceback (most recent call last):
File "c:\Games\Telegram Bot\main.py", line 50, in <module>
bot.polling(none_stop=True)
File "C:\Games\Python\Lib\site-packages\telebot\__init__.py", line 1043, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Games\Python\Lib\site-packages\telebot\__init__.py", line 1118, in __threaded_polling
raise e
File "C:\Games\Python\Lib\site-packages\telebot\__init__.py", line 1074, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Games\Python\Lib\site-packages\telebot\util.py", line 156, in raise_exceptions
raise self.exception_info
File "C:\Games\Python\Lib\site-packages\telebot\util.py", line 100, in run
task(*args, **kwargs)
File "C:\Games\Python\Lib\site-packages\telebot\__init__.py", line 6308, in _run_middlewares_and_handler
result = handler['function'](message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Games\Telegram Bot\main.py", line 24, in start
cursor.execute("INSERT OR REPLACE users VALUES(?, ?, ?);", (user_id, money, bitcoins))
sqlite3.OperationalError: near "users": syntax error
import telebot
from telebot import types
import sqlite3
bot = telebot.TeleBot('Tyt token')
@bot.message_handler(commands=['start'])
def start(message):
global connect, cursor, money, bitcoins
connect = sqlite3.connect("base.db")
cursor = connect.cursor()
money = 0
bitcoins = 0
cursor.execute("""CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT,
money BIGINT,
bitcoin BIGINT
)""")
connect.commit()
user_id = [message.chat.id]
cursor.execute("INSERT OR REPLACE users VALUES(?, ?, ?);", (user_id, money, bitcoins))
connect.commit()
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
stats = types.KeyboardButton("Статистика")
bitcoin_rate = types.KeyboardButton("Биткоин курс")
markup.add(stats, bitcoin_rate)
bot.send_message(message.chat.id, f"Привет, <b>{message.from_user.username}</b>", reply_markup=markup, parse_mode="html")
@bot.message_handler(content_types=['text'])
def sended_message_on_user(message):
if message.chat.type == 'private':
if message.text == 'Статистика':
bot.send_message(message.chat.id, f"Статистика {message.from_user.username}\nДеньги: <b>Бебра</b>", parse_mode="html")
elif message.text == 'Биткоин курс':
bot.send_message(message.chat.id, f"Банк\n\nКурс биткоина: <b></b>", parse_mode="html")
else:
bot.send_message(message.chat.id , "<b>Неизвестная команда</b>", parse_mode="html")
print(f"{message.from_user.username}, ввел неверную команду.")
bot.polling(none_stop=True)