2021-08-20 09:27:19 +00:00
|
|
|
import bson
|
|
|
|
import datetime
|
|
|
|
import json
|
|
|
|
import importlib
|
|
|
|
|
2021-10-08 09:58:19 +00:00
|
|
|
from migration.utils import DateTimeEncoder
|
2021-08-20 09:27:19 +00:00
|
|
|
|
|
|
|
def json_tables():
|
2021-12-17 18:14:31 +00:00
|
|
|
print('creating json files at migration/data/')
|
|
|
|
data = {
|
|
|
|
"content_items": [],
|
|
|
|
"content_item_categories": [],
|
|
|
|
"tags": [],
|
|
|
|
"email_subscriptions": [],
|
|
|
|
"users": [],
|
|
|
|
"comments": []
|
|
|
|
}
|
|
|
|
for table in data.keys():
|
|
|
|
lc = []
|
|
|
|
with open('migration/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
|
2022-06-28 17:27:12 +00:00
|
|
|
open('dump/discours/'+table+'.json', 'w').write(json.dumps(lc,cls=DateTimeEncoder))
|
2021-08-20 09:27:19 +00:00
|
|
|
|