2017-05-11 18:31:59 +02:00
|
|
|
from models import db, Contact
|
2017-05-10 18:41:02 +02:00
|
|
|
from faker import Factory
|
|
|
|
|
|
|
|
fake = Factory.create()
|
|
|
|
# Spanish
|
|
|
|
#fake = Factory.create('es_ES')
|
|
|
|
# Reload tables
|
|
|
|
db.drop_all()
|
|
|
|
db.create_all()
|
|
|
|
# Make 100 fake contacts
|
|
|
|
for num in range(100):
|
|
|
|
fullname = fake.name().split()
|
|
|
|
name = fullname[0]
|
|
|
|
surname = ' '.join(fullname[1:])
|
|
|
|
email = fake.email()
|
|
|
|
phone = fake.phone_number()
|
|
|
|
# Save in database
|
2017-11-11 11:04:25 +01:00
|
|
|
mi_contacto = Contact(name=name, surname=surname, email=email, phone=phone)
|
2017-05-10 18:41:02 +02:00
|
|
|
db.session.add(mi_contacto)
|
2018-05-01 14:35:20 +02:00
|
|
|
|
|
|
|
db.session.commit()
|