我使用 sqlite3 开发了一个简单的 django 应用程序。起初,我想使用 sqlite3 保持简单,但事情开始扩大(是的,我实际上开始使用 sqlite3 的那个应用程序!我真可耻......)所以我想将我所有的数据迁移到 postgresql 数据库。
django 或其他第三方是否提供这样的功能,还是我应该为自己的愚蠢而痛苦......
最佳答案
首先,执行
manage.py dumpdata > out.json
然后更改您的数据库配置、迁移(或同步数据库),最后
echo "delete from auth_permission; delete from django_content_type;" | python manage.py dbshell
(如果你有1.11之前的Django,你需要使用
echo "delete from django_content_type;" | manage.py dbshell
)
然后加载JSON文件:
manage.py loaddata out.json
(自 2013 年起 django_contenttype
被替换为 django_content_type
)
关于database - 如何将正在使用的数据库复制到django中的其他数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7002194/