Sort of like this.... mysql> select id from tbbooks where id = 8; Empty set (0.00 sec)
mysql> select id from tbbooks where id = 1; +----+ | id | +----+ | 1 | +----+ 1 row in set (0.00 sec) On May 26, 2:44 pm, scausten <[email protected]> wrote: > I'm adding files content to my database with the following code being > called onvalidation when the form is submitted. It really simply > generates a 6-digit alphanumeric code as an identifier for the file: > > codes = db().select(db.products.code) # Grabs all the existing codes > from the database > while not form.vars.code: > code = "".join([random.sample(string.ascii_lowercase > +string.digits, 1)[0] for i in range(6)]) # Creates a code > if not code in codes: # If its unique... > form.vars.code = code # ...add it into the form vars > > It works fine at the moment, but I'm hoping to have several hundred > thousand files potentially, and I'm worried that the database call to > pull all existing codes will become a serious bottleneck. The code > needs to be random and not sequential. > > Does anyone have any ideas on how I can do this more elegantly?

