def creating_category(apps, schema_editor): category = apps.get_model("task_Steel_kiwi", "Category") products = apps.get_model("task_Steel_kiwi", "Product") user = apps.get_registered_model("auth", "User") hardware = mimesis.Hardware() text = mimesis.Text() for _ in range(5): randomize_hardware = random.choice( [hardware.cpu(), hardware.graphics()]) category.objects.create( name=randomize_hardware, description=text.text(quantity=3), slug=slug_creator(name=randomize_hardware), ) for _ in range(30): randomize_hardware = random.choice( [hardware.cpu(), hardware.graphics()]) category_n = category.objects.order_by('?').first() products.objects.create( category=category_n, name=randomize_hardware, description=text.text(quantity=3), price=round(random.uniform(10.00, 1000.00), 2), slug=slug_creator(name=randomize_hardware), ) user.objects.create( username='******', password=make_password('adminadmin'), is_staff=True, is_superuser=True, )
def setUp(self): hardware = mimesis.Hardware() text = mimesis.Text() for _ in range(5): randomize_hardware = random.choice( [hardware.cpu(), hardware.graphics()]) Category.objects.create( name=randomize_hardware, description=text.text(quantity=3), slug=slugify(randomize_hardware + '-' + str(slug_creator())), ) for _ in range(30): randomize_hardware = random.choice( [hardware.cpu(), hardware.graphics()]) category_n = Category.objects.order_by('?').first() Product.objects.create( category=category_n, name=randomize_hardware, description=text.text(quantity=3), price=round(random.uniform(10.00, 1000.00), 2), slug=slugify(randomize_hardware + '-' + str(slug_creator())), )
def importToProducer(): try: dsnStr = cx_Oracle.makedsn("217.173.198.135", "1522", "orcltp") con = cx_Oracle.connect(user="******", password="******", dsn=dsnStr) num = int(input("How many rows should be entered? ")) last_id = getLastID("producer") print("Fetching rows...") for x in range(num): a = mimesis.Address('en') h = mimesis.Hardware('en') country = a.country() name = h.manufacturer() query = "INSERT INTO producer (id_producer, name, country) VALUES (:1, :2, :3) " cursor = con.cursor() last_id = last_id + 1 cursor.execute(query, (last_id, name, country)) print(query) cursor.close() con.commit() print("Rows added successfully") except cx_Oracle.Error as error: print("Error occurred:") print(error) consoleInput()
def hard(): return mimesis.Hardware()
full_out = [] for i in range(int(sys.argv[2])): int_out = [] int_out.append(m.Person().username()) int_out.append(m.Person().name()) int_out.append(m.Person().last_name()) int_out.append(m.Person().telephone()) int_out.append(m.Address().address()) int_out.append(m.Address().zip_code()) int_out.append(m.Datetime().date()) int_out.append(m.Datetime().date()) int_out.append(m.Hardware().cpu()) int_out.append(m.Hardware().cpu_frequency()) int_out.append(m.Hardware().graphics()) int_out.append(m.Hardware().manufacturer()) int_out.append(m.Hardware().ram_size()) int_out.append(m.Hardware().ram_type()) int_out.append(m.Hardware().resolution()) int_out.append(m.Games().game()) int_out.append(m.Datetime().date()) int_out.append(m.Text().text(2)) int_out.append(m.Text().text(3)) int_out.append(m.Text().level()) full_out.append(int_out)