Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- import random
- from datetime import datetime
- db = sqlite3.connect('product.db')
- c = db.cursor()
- c.execute('PRAGMA journal_mode=WAL;')
- c.execute('PRAGMA synchronous=NORMAL;')
- c.execute('CREATE VIRTUAL TABLE product USING fts4(itemid, sku, name, slug, desc, d_upload, d_update, spec);')
- sku = ['kwj132123', 'asdsadsad', '123123123', 'ssad12213', '']
- name = 'item'
- desc = 'This item is so good'
- color = ['red', 'pink', 'blue', 'green', 'pale red']
- size = ['us6', 'us7', 'us8', 'us9', 'us10', 'us1']
- brand = ['vans', 'nike', 'reebok', 'addidas', 'puma', 'new balance', 'asics']
- category = 'shoes'
- gender = ['boy', 'girl', 'men', 'women']
- age = ['kids', 'toddler', 'adult']
- for i in range(1, 100001):
- clr = random.choice(color)
- siz = random.choice(size)
- brd = random.choice(brand)
- gnd = random.choice(gender)
- age = random.choice(age)
- specification = ''
- specification += 'color:' + clr + ' '
- specification += 'size:' + siz + ' '
- specification += 'brand:' + brd + ' '
- specification += 'gender:' + gnd + ' '
- specification += 'age:' + age
- now = str(datetime.now())
- if i == 100000:
- specification += ' ' + 'coba:' + 'berhasil'
- data = (str(i), random.choice(sku), name + str(i), name + '-{}'.format(str(i)), desc, now, now, specification)
- c.execute('INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)', data)
- db.commit()
- db.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement