P
P
Python Newbie2021-09-05 18:37:36
Python
Python Newbie, 2021-09-05 18:37:36

How to save data and work with them?

I will give an example:

There is a telegram bot. The user sends him 1 command, and the bot writes to him send the melon. The user submits and this is written to a variable. Then the bot, anywhere in the table, creates a line in which its chat ID is written in column 1, and a data variable is written in column 2. Then the user writes command 2, the bot looks in the table for a line with his chat ID and sends the previously recorded data to the user.

And the question arose at the step where the bot writes all this into some kind of table and then reads it. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
KraGen.Developer, 2021-09-05
@Levman5

Personally, I saved it in textbook. For example, it was necessary to save the password, I wrote it down on line 0 of the tester and then read the first line. I won’t share the code because I don’t remember what and how, but I threw the base so if it’s approximately suitable, then check in Google

V
Vindicar, 2021-09-05
@Vindicar

sqlite3 to the rescue.
I also strongly advise you to learn the basics of SQL and relational databases (the concepts of a table / row / column, what is a primary key and a foreign key and why are they needed, what are the queries). Without this basic knowledge, you will not understand what you are doing.

A
Alexander Nesterov, 2021-09-05
@AlexNest

Use DB.
In the case of python - sqlite for small scales or postgresql for something bigger.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question