Here I set up a procedure that saves up 4 items from a user (username, password, id and phone number) in a list form in a dictionary which for its keys I am using a counter to count number of users who sign up! I would like to know how can I find the correct search for a key in order for a user NOT creating an account with the same Username. NoUser is the number of users which is set to 0 but changes with tinyDB. Usersinfo is the list that takes all 4 texts and save them in a list. DictUsers is the dictionary that I use to save the lists with the key of the number in which this user was there to create the account!
the rest are the blocks that I so far created! Thank you so much in advance.
- Will multiple users use the same device to register their user account ?
- You are overwriting the ListOfUsers value everytime a new user is added...
(I believe you were advised of this issue in your other topic...)
- Same Device. Sort of like the program is running on the Store Owner’s device only (that’s why we are using TinyDB)
- Yeah but for this one, the number of Users (NoUser) is being raised by 1 each time someone creates an account. I thought by setting the Dic key to that number (NoUser), it shouldn’t overwrite or else I don’t understand how the key/value of dictionary works.
Edit: now the way I see it, Is it possible to introduce a Variable as a dictionary, get all user’s accounts, and then store it all into TinyDB, and way later on, if you want to add new accounts, again send the existing stored accounts to a variable, add new ones to it then store now Old + New accounts back into the tinydb?
2nd Edit: I'm dumb, I just noticed that I added such an idea from first edit already but didn't use it. what about this new procedure will it work?
You are still overwriting your ListOfUsers with the last user entry, you need to add the user to your dictionary. Here is a simple example:
With this example, there is one small issue: you can not remove/delete user later.
So the best is to use userid/username as the tag/key, not the number.
I did it that way for speed, the OP maintains a separate tinydb tag for "count" so would then add the next number, not the length of list. This should fix that:
yes, that fix the problem, but still
since if use username as key, you can get his profile just with one block "get value for key". but if use a number as key, we have to loop the dictionary to find user's profile, since it is difficulty for user to remember his id number.
A user could still use their username, but the underlying blocks would need to search all users to find it .
Did I miss the announcement of a competition to make the most convoluted possible solution?
Just fitting it in with how the OP is adding a new user. There are pros and cons in every approach to this.
Was this an entry for the competition as well ?