You need to write a Telegram bot with a personal account in which there will be a user's balance and a specially generated string for the referral link. You can use the dictionary, where the key is the Telegram user ID, and its balance and code for the referral link are values. Is this solution suitable or should you use a database in which all this information will be stored? If you need to use a database, which one would you recommend for a bot written in Python?
It is closed due to the fact that it is necessary to reformulate the question so that it is possible to give an objectively correct answer by the participants of Kromster , jfs , nörbörnën , 0xdb , gil9red May 28 '18 at 6:20 .
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
- Unfortunately I can’t tell about bot in more detail - pinguin
- And where are you going to keep this dictionary? - dzhioev
- @dzhioev if this is a variable, it turns out in RAM. This imposes large restrictions on its size, so it must be stored on the hard disk. Easier to store information in the database, rather than on the hard disk. And you will advise what DB for such task? - pinguin
- oneI think you can’t keep the balance without DB. after all, the server can reboot, so nothing valuable can be stored in RAM. And any database that is more like, for example, postrgeSQL, unless of course you have relational data (which is most likely the case) - Mike
3 answers
If the amount of data is not large and there is no desire to bother with the database, you can use the built-in shelve module. It creates a built-in database, you can record and access the data in it according to the principle of a dictionary.import shelve db = shelve.open(filename) # создание/открытие базы db['spam'] = 'foo' # запись в базу spam = db['spam'] # чтение из базы db.close() # закрытие базы
- Wow, shelve - did not know did not know) - Melis
Well, in general, I think if you envision the use of a bot by a wide circle of people, then the obvious choice would be a DB. And what - this is a separate issue that you have to solve yourself. But I personally recommend SQLite to you. I like it most of all.
You need to store something. The obvious answer is: yes, you need a database. You can get out without it, but why get out :)
The choice of a particular system depends on your preferences. If not, then MySQL will be a good choice, because it is very common.
In short, if there are no special conditions - keep the trend.
- “You can get out without it” —how do you imagine data storage without a database? The question may be "which database to choose": somewhere, the built-in sqlite is appropriate, somewhere is postgres, somewhere redis (nosql) is needed, etcd. - jfs
- @jfs I submit it, but obviously I don’t recommend :) I don’t imagine how to interpret my words differently. - artoodetoo