Answer the question
In order to leave comments, you need to log in
How to "ask" python code, when entering the "start" command, automatically enter the user's ID into the database?
Good afternoon! I can not design the concept of code for automatically assigning id to users in any way. The concept of my task is as follows: a person presses the start button, after which his telegram ID is entered into the database. Question: how can I try to implement code that can assign the main id to the database automatically. For example: the first person wrote to the bot, he is assigned id 1. The second person wrote - he is assigned id 2, etc.
Framework: aiogram
Answer the question
In order to leave comments, you need to log in
What you are asking is called auto_increment ,
but in this case it is not really needed, since user_id is unique in telegrams, it is easier to use it as a key - see code example here . You need to create the create_tables table once and then fill it with the register_user function.
If you decide to add your id based on autoincrement, then just change in the code how the table is created and insert.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question