1👍
✅
You may need to try Mixer
. It Provides fakers
tool to generate most of the useful items for database.
if this is you user model:
class User(db.Model):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), unique=True)
email = db.Column(db.String(255), unique=True)
city = db.Column(db.String(255))
country = db.Column(db.String(255))
you query will be:
from mixer import fakers as f
from models import User
name = f.get_name()
country = f.get_country()
email = f.get_email()
city = f.get_city()
s = db.session
user = User(name=name, email=email, city=city, country=country)
s.add(user)
s.commit()
s.close()
You can more details Here :
Source:stackexchange.com