如何使用manage.py加载.sql文件 [英] How to load .sql file with manage.py

查看:157
本文介绍了如何使用manage.py加载.sql文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一台生产服务器中获得一个.sql文件,现在正尝试将其加载到另一台服务器的数据库中.我尝试了python manage.py loaddata,但它给了我一个错误

I have a .sql file from one of my production servers, and am now trying to load it into the database of another. I tried python manage.py loaddata, but its giving me an error

CommandError: Problem installing fixture 'social': sql is not a known serialization format.

如何使用manage.py将数据从.sql文件加载到postgres中?

How can I load my data into postgres from a .sql file with manage.py ?

推荐答案

按照

fixture是Django知道如何导入到的数据的集合 数据库.创建灯具的最直接方法是 您已经有一些数据可以使用manage.py dumpdata命令

A fixture is a collection of data that Django knows how to import into a database. The most straightforward way of creating a fixture if you’ve already got some data is to use the manage.py dumpdata command

夹具可以编写为 JSON,XML YAML (已安装PyYAML)文档.

Fixtures can be written as JSON, XML or YAML (with PyYAML installed) documents.

加载数据很容易:只需调用manage.py loaddata <fixturename>, 您创建的夹具文件的名称在哪里

Loading data is easy: just call manage.py loaddata <fixturename>, where is the name of the fixture file you’ve created

如果您仍想使用SQL加载数据,则可以进行

If you still want to load data with SQL you could make data migration

这篇关于如何使用manage.py加载.sql文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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