F
F
fukenrice2_02021-10-27 22:45:10
SQL
fukenrice2_0, 2021-10-27 22:45:10

How to cycle through records from the database in a telegram bot?

I am writing a telegram bot on aiogram, with a fairly simple functionality - to accept applications from users and display them one by one for matching (the principle of operation is like in tinder) - the bot displays an application to the user, he answers yes / no, then displays the next application, and so on. At the stage of writing the review of applications, I encountered such a problem - I still don’t understand how to correctly take data from the database so that the questionnaires are not repeated and all records are not stored in memory. There was an idea to just do a random sort and take the first record, but on a small data set there will be too many repetitions with this approach. There was an idea to make an index field, take all records from the database, and just take it by index, but it seems to me that this is not at all memory optimal. I also want to do it completely cyclically,

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-10-27
@fukenrice2_0

Store for each user the id/number of the entry on which he stopped.
There are a few corner cases, like adding a new record after the view has started... but in general it shouldn't be too hard.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question