Django loaddata - 内存不足 [英] Django loaddata - Out of Memory
问题描述
我使用 dumpdata ,它创建了一个500mb的json文件
I made a dump of my db using dumpdata and it created a 500mb json file
现在我试图使用 loaddata 恢复数据库,但是似乎Django尝试加载整个文件在应用它之前进入内存,我得到内存不足错误,进程被杀死。
now I am trying to use loaddata to restore the db, but seems like Django tries to load the entire file into memory before applying it and i get an out of memory error and the process is killed.
没有办法绕过这个问题?
Isn't there a way to bypass this problem?
推荐答案
loaddata
通常用于灯具,即少量数据库对象来获取系统启动并进行测试,而不是大块数据。如果你正在达到内存限制,那么你可能没有使用它来达到正确的目的。
loaddata
is generally use for fixtures, i.e. a small number of database objects to get your system started and for tests rather than for large chunks of data. If you're hitting memory limits then you're probably not using it for the right purpose.
如果你还有原始数据库,你应该使用更适合目的是像PostgreSQL的 pg_dump
或MySQL的 mysqldump
。
If you still have the original database, you should use something more suited to the purpose, like PostgreSQL's pg_dump
or MySQL's mysqldump
.
这篇关于Django loaddata - 内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!