Browse Source

adapting database to user base

master
Erwan Glasziou 6 months ago
parent
commit
56e8250126
  1. 4
      database-update.py

4
database-update.py

@ -48,13 +48,15 @@ for file in bulk_files:
if not chunk:
break
f.write(chunk)
#json downloaded, moving to db
print("Updating cards.db ...\n")
numcard = 0
with open(filename, "r") as f:
rawjson = naya.stream_array(naya.tokenize(f))
batch = []
for card in rawjson:
batch.append(card)
if card["lang"] in ['fr', 'en']:
batch.append(card)
if len(batch) == 512:
cards.insert_all(batch,alter=True,pk="id",batch_size=512)
batch = []

Loading…
Cancel
Save