V
V
VeinKoor2022-03-22 12:59:53
Python
VeinKoor, 2022-03-22 12:59:53

Why does sqlite3 output empty square brackets, +aiogram?

I am writing a bot for a telegram, I ran into a problem that empty square brackets are displayed when querying the database

@dp.message_handler(content_types=['text'])
async def profile(msg: types.Message):
    if msg.text.lower() == "профиль":
        cursor.execute("SELECT * FROM users WHERE chat_id = '{msg.chat.id}'")

        data = cursor.fetchall()
        print(data)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VeinKoor, 2022-03-22
@VeinKoor

Problem already fixed

@dp.message_handler(content_types=['text'])
async def profile(msg: types.Message):
    if msg.text.lower() == "профиль":
        cursor.execute("SELECT * FROM users WHERE chat_id = '{msg.chat.id}'")
        for value in cursor.execute(f"SELECT * FROM users WHERE chat_id = '{msg.chat.id}'"):
            print(value[0], value[1], value[2])
            await msg.answer(f"id: " + value[0] + "\n\n" + "Имя: " + value[1] + "\n\n" + "Баланс: " + str(value[2]))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question