假设我们有MongoDB,我们希望将数据备份到.json文件中作为输出文件的示例:database.json
和内部:
{
"collections": [
{"name": "admin"},
{"name": "class"},
{"name": "lesson"},
{"name": "message"},
{"name": "room"},
{"name": "student"},
{"name": "subject"},
{"name": "teacher"}
],
"subjects": [
{
"name": "Null",
"color": "#FFFFFF"
},
{
"name": "Design Art",
"color": "#82B9D6"
},
{
"name": "Plastic Art",
"color": "#a3db05"
},
{
"name": "Media And Production",
"color": "#522a64"
}, //...there is a continue to this file ....
}
应将每个集合添加到集合中,并且对于每个集合,应该有一个包含其中所有信息的数组(如上所述)
我使用python 3.4和pymongo驱动程序。
从DB获取所有信息的最佳方法是什么,创建JSON对象并将其插入 new .json文件
答案 0 :(得分:0)
我找到了这种方式:
if