Guest User

Untitled

a guest
Dec 17th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import random
  2.  
  3. used = set()
  4. for i in range(0, 10):
  5. # Get a random row from my database
  6. bank_account = random_table_row(datatablebootstrap.BankAccount)
  7. # Generate a random check number from 10 to 50
  8. check_number = str(random.randrange(10, 50))
  9. # Until the combination of bank_account.id and check_number is unique, keep getting another check_number
  10. while ((bank_account.id, check_number) in used):
  11. check_number = str(random.randrange(10, 50))
  12.  
  13. # populate the database with the new check data
  14. new_check(bank_account.id, check_number)
  15. # add the 2-tuple to the set of used 2-tuples so it will not be used again
  16. used.add((bank_account.id, check_number))
Add Comment
Please, Sign In to add comment