role_id and topic relations fixes
This commit is contained in:
30
migration/bson2json.py
Normal file
30
migration/bson2json.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import bson
|
||||
import datetime
|
||||
import json
|
||||
import importlib
|
||||
|
||||
import DateTimeEncoder from utils
|
||||
|
||||
data = {
|
||||
"content_items": [],
|
||||
"content_item_categories": [],
|
||||
"tags": [],
|
||||
"email_subscriptions": [],
|
||||
"users": [],
|
||||
"comments": []
|
||||
}
|
||||
|
||||
def json_tables():
|
||||
print('creating json files at data/')
|
||||
|
||||
for table in data.keys():
|
||||
lc = []
|
||||
with open('data/'+table+'.bson', 'rb') as f:
|
||||
bs = f.read()
|
||||
base = 0
|
||||
while base < len(bs):
|
||||
base, d = bson.decode_document(bs, base)
|
||||
lc.append(d)
|
||||
data[table] = lc
|
||||
open('data/'+table+'.json', 'w').write(json.dumps(lc,cls=DateTimeEncoder))
|
||||
|
Reference in New Issue
Block a user