TypeError: string indices must be integers on ArangoDB

310 Views Asked by At

Arango module gives a weird error while accessing databases:

from arango import ArangoClient 
client = ArangoClient(hosts='http://localhost:8529/') 
sys_db = client.db('_system', username='root', password='root')
sys_db.databases()

below is the error:

Traceback (most recent call last): File "", line 1, in File "/home/ubuntu/arangovenv/lib/python3.6/site-packages/arango/database.py", line 699, in databases return self._execute(request, response_handler) File "/home/ubuntu/arangovenv/lib/python3.6/site-packages/arango/api.py", line 66, in _execute return self._executor.execute(request, response_handler) File "/home/ubuntu/arangovenv/lib/python3.6/site-packages/arango/executor.py", line 82, in execute return response_handler(resp) File "/home/ubuntu/arangovenv/lib/python3.6/site-packages/arango/database.py", line 697, in response_handler return resp.body['result'] TypeError: string indices must be integers

calling database module from "packages/arango/database.py" giving me the same error.

my env:

1) ubuntu 16.4

2) python-arango==5.2.1

any help appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

If you are running it on some server, it may be a server issue. It was in my case at least. I ran the following to clear the proxy and it worked fine.

export http_proxy=''
3
On

As I guessed, resp.body is not the data type that you provided. line 697 of database.py is expecting something else. For example:

>>> data = "MyName"
>>> print(data[0])
'M'
>>> print(data['anything'])
TypeError: string indices must be integers

First print command gives the result while seconds command throws the error.

I hope this might solve your problem.