Answer the question
In order to leave comments, you need to log in
How to solve the problem in telebot/sqlite3?
How can I make sure that all the people who started the bot are entered into the database?
import sqlite3
import telebot
bot = telebot.TeleBot('Токен')
db = sqlite3.connect('TG.db', check_same_thread=False)
sql = db.cursor()
sql.execute("""CREATE VIRTUAL TABLE IF NOT EXISTS Started USING fts4(
id TEXT,
username TEXT
)""")
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, 'Привет')
username = '{0}{1}'.format('@', message.from_user.username)
uid = message.chat.id
sql.execute(f"SELECT id FROM Started WHERE id = '{uid}'")
if sql.fetchone() is None:
sql.execute(f"INSERT INTO Started VALUES (?,?)", (username, uid))
db.commit()
bot.polling()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question