bson-fix
This commit is contained in:
parent
743ab1e18f
commit
3eba61b36f
|
@ -15,18 +15,18 @@ def json_tables():
|
||||||
"email_subscriptions": [],
|
"email_subscriptions": [],
|
||||||
"users": [],
|
"users": [],
|
||||||
"comments": [],
|
"comments": [],
|
||||||
|
"remarks": []
|
||||||
}
|
}
|
||||||
for table in data.keys():
|
for table in data.keys():
|
||||||
|
print('[migration] bson2json for ' + table)
|
||||||
gc.collect()
|
gc.collect()
|
||||||
lc = []
|
lc = []
|
||||||
with open("dump/discours/" + table + ".bson", "rb") as f:
|
bs = open("dump/discours/" + table + ".bson", "rb").read()
|
||||||
bs = f.read()
|
base = 0
|
||||||
f.close()
|
while base < len(bs):
|
||||||
base = 0
|
base, d = bson.decode_document(bs, base)
|
||||||
while base < len(bs):
|
lc.append(d)
|
||||||
base, d = bson.decode_document(bs, base)
|
data[table] = lc
|
||||||
lc.append(d)
|
open(os.getcwd() + "/migration/data/" + table + ".json", "w").write(
|
||||||
data[table] = lc
|
json.dumps(lc, cls=DateTimeEncoder)
|
||||||
open(os.getcwd() + "/migration/data/" + table + ".json", "w").write(
|
)
|
||||||
json.dumps(lc, cls=DateTimeEncoder)
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user