Answer the question
In order to leave comments, you need to log in
How to display everything that is in the database (SQLite3) in one line, and not separately Python, Aiogram?
I have a code (function) that, with a certain command (!all_ID), displays everything (in our case, the username of users) in the chat on behalf of the bot. it is necessary that the bot displays all this in one line , and not separately . the bot displays as follows:
the first message from the bot: @username1
the second message from the bot next: @username2
It is required from the bot that it write like this, separated by commas :
one message from the bot: @username1 , @username2
here is the whole code:
@dp.message_handler(is_admin=True, commands=["all_ID"],commands_prefix="!/")
async def allid(message: types.Message):
connect = sqlite3.connect('usersnames.dp')
cursor = connect.cursor()
select_all_rows = "SELECT * FROM 'username'"
cursor.execute(select_all_rows)
rows = cursor.fetchall()
for row in rows:
await dp.bot.send_message(message.chat.id, text = f'@{row[0]}')
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