开发者

Pull data from production to dev for debugging (Django)

This is what I want: [Production MySQL Data] -> [Development MySQL Data]

For debugging or improvement, I occasionally need to have a copy of the data running on the production site to be present in my development environment. Obviously I don't want to actually use the production database and manually entering the data is out of the question.

Are there any admin scripts out ther开发者_如何学Pythone that allow this to happen (preferably using Django's management interface) effortlessly and painlessly? What would be ideal would be something like:

manage.py reverse_sync [appname]

Or perhaps manage.py reverse_sync [appname] 500 to get only the first 500 records.


You want to use

manage.py dumpdata [appname ...]

to get the data out for one or more apps. This will create a fixture file that you can use in unit tests or just a database agnostic format.

To load the data all you need is

manage.py loaddata fixturename [...]

and it will put it in the database the corresponds to your settings.


manage.py dumpdata can dump DB data as a fixture for one or more apps. I don't think there is a way to get only X records through that, though. You could always use shell, do the query and serialize it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜