Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- from faker import Faker
- from elasticsearch import Elasticsearch
- import random
- fake = Faker()
- es = Elasticsearch()
- tables = [ fake.first_name().lower() for i in range(5) ]
- n = 0
- while True:
- n += 1
- doc = { 'name': fake.first_name(),
- 'surname': fake.last_name(),
- 'company': fake.company(),
- 'address': fake.address(),
- 'email': fake.ascii_safe_email(),
- 'timestamp': datetime.now(),
- }
- t = random.choice(tables)
- res = es.index(index=t, doc_type="faker", id=n, body=doc)
- print("{} {}".format(n, res['result']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement