Answer the question
In order to leave comments, you need to log in
How to add a new ORDER BY from sqlite3 to the bot?
Using the /top command, the bot displays the 5 users with the largest numbers:
username1: username1
username2: username2
username3: username3
username4: username4
username5: username5
@dp.message_handler(commands=['top'])
async def top(message: types.Message):
conn = sqlite3.connect('db.db')
with conn:
cur = conn.cursor()
cur.execute("SELECT * FROM users ORDER BY money DESC LIMIT 5")
data = cur.fetchall()
text = '\n'.join((f'{row[1]}: {row[5]} - монеты' for row in data))
await message.reply(text)
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