python - How to Generate Fixtures from Database with SqlAlchemy -
i'm starting write tests flask-sqlalchemy, , i'd add fixtures those. have plenty of data in development database , lot of tables writing data manually annoying. i'd sample data dev database fixtures , use those. what's way this?
i use factory boy
to create model factory do:
import factory . import models class userfactory(factory.factory): class meta: model = models.user first_name = 'john' last_name = 'doe' admin = false
then create instances:
userfactory.create()
to add static data give kwarg create
userfactory.create(name='hank')
so seed bunch of stuff throw in loop. :)
Comments
Post a Comment