I am trying out sample queries using Python plugin.
Query:
name: string @index(term) @lang .
age: int @index(int) .
friend: uid @count .
This worked fine on the browser:
Same query is crashing from Python.
Code:
import pydgraph
client_stub = pydgraph.DgraphClientStub('localhost:9080')
client = pydgraph.DgraphClient(client_stub)
query = """name: string @index(term) @lang .
age: int @index(int) .
friend: uid @count ."""
result = client.alter(query)
print(result)
Stacktrace:
ERROR:root:Exception serializing message!
Traceback (most recent call last):
File "/home/galaxia/PycharmProjects/helloworld/venv/lib/python3.5/site-packages/grpc/_common.py", line 87, in _transform
return transformer(message)
TypeError: descriptor 'SerializeToString' requires a 'google.protobuf.pyext._message.CMessage' object but received a 'str'
Traceback (most recent call last):
File "/home/galaxia/Documents/bitbucket repo/Dgraph/schema.py", line 10, in <module>
result = client.alter(query)
File "/home/galaxia/PycharmProjects/helloworld/venv/lib/python3.5/site-packages/pydgraph/client.py", line 42, in alter
return self.any_client().alter(op, timeout=timeout, metadata=metadata, credentials=credentials)
File "/home/galaxia/PycharmProjects/helloworld/venv/lib/python3.5/site-packages/pydgraph/client_stub.py", line 36, in alter
return self.stub.Alter(op, timeout=timeout, metadata=metadata, credentials=credentials)
File "/home/galaxia/PycharmProjects/helloworld/venv/lib/python3.5/site-packages/grpc/_channel.py", line 486, in __call__
credentials)
File "/home/galaxia/PycharmProjects/helloworld/venv/lib/python3.5/site-packages/grpc/_channel.py", line 471, in _blocking
raise rendezvous
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INTERNAL, Exception serializing request!)>