1

I'm testing the ability to store PyTest results, generated by the json plugin for that test harness, into ArangoDB. I am attempting to import as follows

import pyArango.connection as adbConn
dbConn = adbConn.Connection(...)
db = dbConn['mydb']
collection = db.collections['PyTestResults']
collection.bulkImport_json('/path/to/results.json')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/pyArango/collection.py", line 777, in bulkImport_json
    errorMessage = "At least: %d errors. The first one is: '%s'\n\n more in <this_exception>.data" % 
(len(data), data[0]["errorMessage"])
TypeError: string indices must be integers

What isn't making sense is that the JSON file is properly formed. In fact, using the regular Python JSON module, it works just fine:

import json
with open('/path/to/results.json') as fd:
    data = json.load(fd)

print(data)

This works. The beginning of the file is

{"report": 
    {"environment": 
        {
            "Python": "3.6.9", "Platform": "Linux-4.4.0-17763-Microsoft-x86_64-with-Ubuntu-18.04-bionic"
        },

It seems that the library, pyArango, is wanting the keys to be integers. I tried this, that is I tried changing "report" to 0. However, this resulted in invalidating the JSON structure.

How is one to use the pyArango library to import JSON? The overall structure of this JSON file doesn't look much different than any of the examples in this page. Any pointers are greatly appreciated.

Andrew Falanga
  • 2,274
  • 4
  • 26
  • 51
  • I will postpone "voting" to delete my own question a few more days as I hope someone will know the answer. However, I have found a solution to the problem of inserting new records in JSON. I'm using `pyArango.collection.createDocument()` and then `.save()`. Though a solution it doesn't answer the question about bulk importation which I hope to yet resolve. – Andrew Falanga May 04 '20 at 19:19
  • Could you please post your solution as the answer to your question? – ishigoya Jan 28 '21 at 16:07

0 Answers0