def get_user_columns(id): cols = [] user = RandomUser() cols.append(id) cols.append(user.get_first_name()) cols.append(user.get_last_name()) cols.append('{} {}, {} {}'.format(user.get_street(), user.get_city(), user.get_state(), str(user.get_zipcode()))) cols.append(user.get_email()) cols.append(user.get_password()) return cols
def create_order_address(mycursor): user = RandomUser() sql = ''' INSERT INTO `ecommerce_address` (`first_name`, `last_name`, `phone_number`, `street`, `city`, `postcode`, `created_at`, `updated_at`, `country_code`, `province_code`, `province_name`) VALUES (%s, %s, %s, %s, %s, %s, now(), now(), 'PT', NULL, NULL); ''' args = (user.get_first_name(), user.get_last_name(), user.get_phone(), user.get_street(), user.get_city(), user.get_postcode()) mycursor.execute(sql, args) return mycursor.lastrowid
def generate_sponsor(i): exists = True while exists: print(f"Generating Random Sponsor {i}") random_user = RandomUser({'nat': 'us', 'gender': 'male'}) name = " ".join(random_user.get_street().split()[1:-1]) name += " Auto Parts" exists = Sponsor.query.filter_by(name=name).first() random_picture = requests.get(random_user.get_picture()) random_name = secrets.token_hex(8) _, extension = os.path.splitext(random_user.get_picture()) file_name = random_name + extension path = os.path.join(app.root_path, "static/profile_pictures", file_name) size = 500, 500 picture = Image.open(BytesIO(random_picture.content)) picture.thumbnail(size) picture.save(path) sponsor = Sponsor(name=name, picture=file_name) catalog = Catalog(sponsor=sponsor) db.session.add(sponsor) db.session.add(catalog)