S
S
Skauyt2021-05-01 17:20:11
Python
Skauyt, 2021-05-01 17:20:11

How to output multiple sqlite lines in one vk py message?

I wrote a small code that allows you to get all the information about users in the database. The output of messages works fine, but one thing bothers me. The function itself displays information in each new message, that is, one message per user. I need to be able to display everything in one message by the VKontakte bot. How can I do that? I would be grateful for the help
The code itself:

def vivod_inf():
  for i in sql.execute(f"SELECT id,nick,dostyp FROM users"):
    write_message(sender, f"{i[0]}({i[1]}), уровень доступа - {i[2]}")


information output:
608d6357ddd75907103323.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bryuliks don't care how old you, 2021-05-01
@Skauyt

def vivod_inf():
  o = ""
  for i in sql.execute(f"SELECT id,nick,dostyp FROM users"):
      o += f"{i[0]}({i[1]}), уровень доступа - {i[2]}\n"
  write_message(sender, o)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question