def generate_fake(count=100): from sqlalchemy.exc import IntegrityError from random import seed from forgery_py import name, date, internet, address, personal seed() for i in range(count): p = Person(name.first_name(), name.last_name(), date.date(), personal.gender(), address.phone(), internet.email_address(), address.street_address(), address.city(), address.state_abbrev(), address.zip_code()) db.session.add(p) try: db.session.commit() except IntegrityError: db.session.rollback()
def generate_fake(count=100): from sqlalchemy.exc import IntegrityError from random import seed, randint from forgery_py import name, internet, address seed() reading_levels = ['Teen', 'Adult', 'Children'] for i in range(count): current_reading_level = reading_levels[randint(0,2)] rl = ReadingLevels.query.filter(ReadingLevels.reading_level == current_reading_level).first() c = Client(name.full_name(), address.phone(), internet.email_address(), address.street_address(), address.city(), address.state_abbrev(), address.zip_code(), current_reading_level, name.last_name()) rl.clients.append(c) try: db.session.add(c) db.session.commit() except IntegrityError: db.session.rollback()