开发者

manage.py datadump of a large database in Django 1.1 (creating testdatabase)

To be able to do some decent unittests I want to create a testdatabase. After reading the Django docs, I came to the conclusion that the best way to do this is by creating a testdatabase from the actual database, with the use of fixtures.

To create such a fixture, one is to run:

./manage.py dumpdata appname --indent 2

After dumping, I want to edit the file, and select the data I actually want to use. However, dumping it almost crashes my PC (the scripts starts trashing I think). Also, it seems to first get all data in memory, and then print it all out at once.

The database I'm using is MySQL

Is there a way to get the data out the database without crashing my PC, in a format usable as fixture?

(an alternative which I'm considering is redefining the default datamanager for the objects with lots of rows, 开发者_JAVA百科to return only needed rows, but that seems like a rather nasty hack, which I'd rather not apply)


You should take a look at this ticket and apply the supplied patch. @ramiro recently ran tests to compare the trunk against his latest patch and you can see there is a huge difference in memory consumption at the expense of processing time:

manage.py datadump of a large database in Django 1.1 (creating testdatabase)

manage.py datadump of a large database in Django 1.1 (creating testdatabase)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜