I Want to Do
I’m using pydgraph to import data into dgraph.What makes me sad is that it takes a long time to import a large amount of data . Every time I import data one by one, I want to know whether dgraph can batch import data?
Import data in this way:
https://github.com/dgraph-io/pydgraph#running-a-mutation
Code :
for file in file_list:
get_data = ExcelData(data_path, sheetname)
datas = get_data.readExcel()
for row in range(int(len(datas))):
txn = self.client.txn()
value = list(datas[row].values())
item_info = self.check_info(value[0])
try:
item = {
'uid': '{}'.format(item_info),
'dgraph.type': 'obj',
'id': value[0],
'name': value[1],
'grade': value[2],
'class': value[3],
'region': value[4],
'org': value[5],
}
print(item)
response = txn.mutate(set_obj=item)
txn.commit()
finally:
txn.discard()