Making a django Fixture that gets 100 items from each Table, or follows foreign keys
Asked Answered
M

2

0

I need to create some fixtures for django test. Does anyone know of a shortcut that lets me get x number of rows from every table in database and serialize it?

Background: I have Multiple tables with 10's of millions of entries. I have tried to use the ./manage.py dumpdata, but in addition to taking too long there is no way fixture should be that large. Each table has multiple foreign keys.

The Problem: The code I am trying to test frequently calls select_related() Meaning I need all the foreign key relationships filled in.

Does anyone know of any tools that can help me follow foreign relationships for serializing DB data??? Any suggestions would be greatly appreciated. Thank you for your time.

Mum answered 8/4, 2011 at 18:37 Comment(1)
The autofixtures were all very good solutions but I needed my real data. I ended up making a tool to make fixtures for a queryset and all it's foreign keys. github.com/dm03514/FixtureMakerMum
D
2

I have used the django-autofixture pluggable apps in a couple projects. You could give that a shot. Instead of using data from your database for tests, create a development database filled with autofixtures.

This link has a few other examples of similar pluggable apps.

http://djangopackages.com/grids/g/fixtures/

Dysgraphia answered 8/4, 2011 at 22:9 Comment(1)
whoa ty, those are a lot of options, ty.Mum
T
0

Another option is the tool Dynamic Dynamic Fixture, that follow Foreign Keys and Many to Many fields. Also, you can use the option "number_of_laps" that may help you.

Turaco answered 13/11, 2012 at 0:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.