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

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -