-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_fake_pt.py
67 lines (55 loc) · 1.75 KB
/
insert_fake_pt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# This script populates a MongoDB collections with fake users
# Based on Brazilian location
# Christiano Anderson
# Twitter: @dump
# Blog: http://christiano.me
import pymongo
from faker import Factory
fake = Factory.create('pt_BR')
for cod in range(0,10000):
cli = pymongo.MongoClient('mongodb://localhost:30011,localhost:30012,localhost:30013/?replicaSet=rs1')
db = cli['empresa']
doc = {
'nome': fake.name(),
'email': fake.email(),
'nascimento': fake.date_time_between(start_date="-30y", end_date="now", tzinfo=None),
'enderecos': [
{
'tipo': 'Residencial',
'logradouro': fake.street_name(),
'numero': fake.building_number(),
'bairro': fake.bairro(),
'cidade': fake.city(),
'uf': fake.estado_sigla(),
'cep': fake.postcode(),
},
{
'tipo': 'Comercial',
'cargo': fake.job(),
'empresa': fake.company(),
'logradouro': fake.street_name(),
'numero': fake.building_number(),
'bairro': fake.bairro(),
'cidade': fake.city(),
'uf': fake.estado_sigla(),
'cep': fake.postcode(),
},
],
'telefones': [
{
'tipo': 'Celular',
'numero': fake.phone_number(),
},
{
'tipo': 'Residencial',
'numero': fake.phone_number(),
},
{
'tipo': 'Comercial',
'number': fake.phone_number(),
},
]
}
db.funcionarios.insert(doc)
print(doc['nome'])