# Error in my sample code

**URL:** <https://discuss.dgraph.io/t/error-in-my-sample-code/8231>\
**Category:** Dgraph Clients\
**Tags:** untagged, pydgraph\
**Created:** [September 12, 2019, 10:08am UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231 "2019-09-12T10:08:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 12, 2019, 10:08am UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231/1 "2019-09-12T10:08:41Z")

</div>

**Moved from GitHub [pydgraph/86](https://github.com/dgraph-io/pydgraph/issues/86)**

_Posted by_ [Xls1994](https://github.com/Xls1994):

Hi, I write a simple code like this:

```python
client_stub =pydgraph.DgraphClientStub("spark-1:9082")
client =pydgraph.DgraphClient(client_stub)
txn =client.txn()
p={
    #'uid':'0x12',
    'name':'Tony11',
    'city':'Franch',
}
print p
try:
    assigned = txn.mutate(set_obj=p)
    txn.commit()
finally:
    txn.discard()

client_stub.close()

```

However I got a error with this code as follows:

```auto
Traceback (most recent call last):
  File "dgraphTest.py", line 12, in <module>
    assigned = txn.mutate(set_obj=p)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 71, in muta
te
    return self.do_request(req, timeout=timeout, metadata=metadata, credentials=
credentials)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 110, in do_
request
    self._common_except_mutate(query_error)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 160, in _co
mmon_except_mutate
    raise error
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Empty query"
        debug_error_string = "{"created":"@1568282122.945000000","description":"
Error received from peer ipv4:10.18.216.230:9082","file":"src/core/lib/surface/c
all.cc","file_line":1052,"grpc_message":"Empty query","grpc_status":2}"

```

the version of pydgraph is 2.0.2.  
the version of Dgraph is v1.0.16  
I could not understand what/s wrong with my code, please help me. Thanks!

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 12, 2019, 5:57pm UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231/2 "2019-09-12T17:57:00Z")

</div>

[martinmr](https://github.com/martinmr) _commented_ :

Can you try version 1.2 of pydgraph? Versions \>2 have an API change that makes it incompatible with the 1.0.x Dgraph series.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 12, 2019, 5:57pm UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231/3 "2019-09-12T17:57:22Z")

</div>

[martinmr](https://github.com/martinmr) _commented_ :

I’ll update the readme to include this information

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 16, 2019, 9:29am UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231/4 "2019-09-16T09:29:01Z")

</div>

[Xls1994](https://github.com/Xls1994) _commented_ :

Thanks, the 1.2 version is right to write data to dgraph.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 4:28am UTC](https://discuss.dgraph.io/t/error-in-my-sample-code/8231/5 "2020-07-11T04:28:51Z")

</div>

Closed on July 11, 2020, 4:28am UTC


