Answer the question
In order to leave comments, you need to log in
Mailing to all id, sends so far only to the first in the database?
Tell me if there is a base.db base , user ids
are recorded in it,
I need to organize a mailing list for all users of the bot, but for some reason it does not display all ids, but only the first one, why?
def all_id():
conn = sqlite3.connect('base.db')
cursor = conn.cursor()
cursor.execute('SELECT id FROM users')
words = cursor.fetchall()
conn.commit()
cursor.close()
conn.close()
return words[0]
elif mail == True:
mail = False
text = base_work.all_id()
bot.send_message(message.chat.id, 'В течении 3 секунд, отправиться всем пользователям!')
for i in text:
try:
bot.forward_message(i, message.chat.id, disable_notification=True, message_id=message.message_id)
except:
pass
bot.send_message(message.chat.id, 'Все')
Answer the question
In order to leave comments, you need to log in
Something like this:
def all_id():
conn = sqlite3.connect('base.db')
cursor = conn.cursor()
cursor.execute('SELECT id FROM users')
words = cursor.fetchall()
conn.commit()
cursor.close()
conn.close()
return words
for x in all_id():
print(x[0])
You return all_id
only one element from the function.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question