A
A
Aztart2021-05-17 14:06:01
Python
Aztart, 2021-05-17 14:06:01

How to assign individual user values ​​to global variables?

I need global variables in the telegram bot code that contain the values ​​​​of a particular user (for example, the number of messages of this user, the time the bot was used), so that each user has their own values, and not common ones.
Is it possible to do this without using a database? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-05-17
@Aztart

It is possible to do this without a DB, but what's the point? After restarting the bot, all data will be lost. Plus, with a large amount of data, your RAM space will simply grow.
It's better to do everything through the database. This is more correct from an architectural point of view. If you are worried about the speed of processing requests, then it all depends on the code and architecture. You can write a banal sample from a table of 100 rows with subsequent processing so bad that the delays will be very noticeable. And you can do it well, then the processing of hundreds of thousands of database rows will be invisible to the user.
So if you are worried about performance, think about the architecture of the program, read development books, and experiment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question