I am using Python to interact with a MySQL database. I have a function that allows a user to create an account. The parameters of this function are their full name, email, and password. These parameters are the input fields required to create an account.
Based on the “full name” or “email” parameter I would like to generate a unique username for a user. This username can then be changed at a later date by the user. Usernames will be used to lookup other users (by the use of a search function etc) and so should be in a more human readable format than that of a UUID etc. What is the best approach for this?
Should I generate a list of random names (using some random function) and then iterate through the array until I find the first username that is not found in the database, then assign it to the user? Or is there a better, more efficient approach?