Answer the question
In order to leave comments, you need to log in
How to make sure that the information in the database is not repeated sql telebot?
In python, for each user, a tag is generated and written to the table, if a person wants, he can change it. How to make it so that when editing it, a person could not put a tag that another user already has.
Answer the question
In order to leave comments, you need to log in
You can impose a unique index on the field, then when you try to make a duplicate, there will be a sql error that can be intercepted and processed as you need, for example, ask to change the selected tag.
If sql error does not suit you, then you can try to check for the existence of the tag value in the database before inserting / changing the tag, for example:
select 1 from table where tag = 'New tag'
If the query returned 1, then this tag is already in the database and you need to come up with another one.
In all SQL databases, you can add a unique index, which will ensure the uniqueness of the values in the column.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question