Telegram bot не рабтает с базой данных
Telegram bot не работает с базой данных. sqlite3.OperationalError: no such table: users. Вроде бы все провельно.
import telebot
bot = telebot.TeleBot("5456447840:AAHM-f1K7_XsmYLJZDiYxV5f9-79MGy_-rg")
@bot.message_handler(command = ['start'])
def start(message):
conn = sqlite3.connect('database.db', check_same_thread=False)
cursor = conn.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS users (
id TEXT,
fname TEXT,
lname TEXT,
coin INT);""")
conn.commit()
cursor.close()
conn.close()
@bot.message_handler(commands=['join'])
def join(message):
bot.send_message(message.chat.id, 'input your id')
bot.register_next_step_handler(message, idEnter)
def idEnter(message):
conn = sqlite3.connect('database.db', check_same_thread=False)
cursor = conn.cursor()
bot.send_message(message.chat.id,message.text)
text = message.text
cursor.execute("""SELECT id FROM users WHERE id = ?""", [text])
if cursor.fetchall() is None:
bot.send_message(message.chat.id,"This id is not create")
else:
bot.send_message(message.chat.id, cursor.fetchone())
cursor.close()
conn.close()
bot.polling(non_stop=True)```