将数据从生产提取到开发人员进行调试(Django) [英] Pull data from production to dev for debugging (Django)

查看:122
本文介绍了将数据从生产提取到开发人员进行调试(Django)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要的: [生产MySQL数据] - > [开发MySQL数据]

调试或改进,我偶尔需要在生产站点上运行的数据副本存在于我的开发环境中。显然,我不想实际使用生产数据库并手动输入数据是不成问题的。

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.

是否有任何管理脚本允许这种情况发生(最好使用Django的管理界面)毫不费力地和无痛地?最理想的是这样的:

Are there any admin scripts out there 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]

或者可能 manage.py reverse_sync [appname] 500 仅获取前500条记录。

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

推荐答案

你想使用

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.

这篇关于将数据从生产提取到开发人员进行调试(Django)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆