# Python Insert script not working

**URL:** <https://discuss.dgraph.io/t/python-insert-script-not-working/14316>\
**Category:** Dgraph Cloud\
**Tags:** kind:question, python\
**Created:** [May 26, 2021, 12:19am UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316 "2021-05-26T00:19:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krisraman](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@krisraman](https://discuss.dgraph.io/u/krisraman)\
**Post date:** [May 26, 2021, 12:19am UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316/1 "2021-05-26T00:19:52Z")

</div>

Here is the example script that I tried:

**test.py:**

```auto
import pydgraph

client_stub = pydgraph.DgraphClientStub.from_slash_endpoint("https://ancient-lake.us-west-2.aws.cloud.dgraph.io/graphql", <api-key>)
client = pydgraph.DgraphClient(client_stub)
txn = client.txn()
p = {
        'dgraph.type' : 'User',
        'username' : 'KrisR'
}
try:
        txn.mutate(set_obj=p)
        txn.commit()
finally:
        txn.discard()

```

I get the following error. Can you please help?

```auto
  File "dgraphaccess.py", line 11, in <module>
    txn.mutate(set_obj=p) 
  File "/usr/local/lib/python3.8/dist-packages/pydgraph/txn.py", line 75, in mutate
    req = self.create_request(mutations=[mutation], commit_now=commit_now)
  File "/usr/local/lib/python3.8/dist-packages/pydgraph/txn.py", line 197, in create_request
    resp_format = api.Request.RespFormat.JSON
AttributeError: 'EnumTypeWrapper' object has no attribute 'JSON'

```

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [May 26, 2021, 12:41am UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316/2 "2021-05-26T00:41:26Z")

</div>

Hi @krisraman - welcome to the Dgraph forums! We hope you enjoy the stay.

Can you tell me which version of PyDgraph you are using? I just tried reproducing your code and it works correctly. (mine is pydgraph-21.3.0)

---

<div class="post-metadata">

**Author:** ![krisraman](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@krisraman](https://discuss.dgraph.io/u/krisraman)\
**Post date:** [May 26, 2021, 5:51pm UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316/3 "2021-05-26T17:51:36Z")

</div>

Hi @chewxy , Thanks for looking into my issue. I am running pydgraph 21.3.0 as well.

Kris

---

<div class="post-metadata">

**Author:** ![krisraman](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@krisraman](https://discuss.dgraph.io/u/krisraman)\
**Post date:** [May 26, 2021, 5:53pm UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316/4 "2021-05-26T17:53:09Z")

</div>

Here is the detail

pip show pydgraph

Name: pydgraph  
Version: 21.3.0  
Summary: Official Dgraph client implementation for Python  
Home-page: [GitHub - dgraph-io/pydgraph: Official Dgraph Python client](https://github.com/dgraph-io/pydgraph)  
Author: Dgraph Labs  
Author-email: [contact@dgraph.io](mailto:contact@dgraph.io)  
License: Apache License, Version 2.0  
Location: /usr/local/lib/python3.8/dist-packages  
Requires: protobuf, grpcio  
Required-by:

---

<div class="post-metadata">

**Author:** ![krisraman](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@krisraman](https://discuss.dgraph.io/u/krisraman)\
**Post date:** [May 27, 2021, 9:57pm UTC](https://discuss.dgraph.io/t/python-insert-script-not-working/14316/5 "2021-05-27T21:57:55Z")

</div>

Hi @chewxy , Any update? Is there anything I should check. Am in the process of choosing a graph db and your response would help me with evaluation. Thanks

Kris
