{"id":24315,"library":"pydgraph","title":"pydgraph","description":"Official Python client for Dgraph, a distributed graph database. Version 25.2.0 supports Dgraph v25 API, requires Python >=3.9, and uses gRPC for communication. Release cadence is approximately quarterly.","status":"active","version":"25.2.0","language":"python","source_language":"en","source_url":"https://github.com/dgraph-io/pydgraph","tags":["graph","database","dgraph","grpc"],"install":[{"cmd":"pip install pydgraph","lang":"bash","label":"Latest version"},{"cmd":"pip install pydgraph==25.2.0","lang":"bash","label":"Pin specific version"}],"dependencies":[{"reason":"gRPC communication with Dgraph server","package":"grpcio","optional":false},{"reason":"Protocol Buffers for data serialization","package":"protobuf","optional":false}],"imports":[{"wrong":"from pydgraph import stub","symbol":"DgraphClient","correct":"from pydgraph import DgraphClient"},{"symbol":"DgraphClientStub","correct":"from pydgraph import DgraphClientStub"},{"symbol":"Txn","correct":"from pydgraph import Txn"}],"quickstart":{"code":"import pydgraph\n\n# Create a client stub\nclient_stub = pydgraph.DgraphClientStub('localhost:9080')\n# Create a client\nclient = pydgraph.DgraphClient(client_stub)\n\n# Set schema\nschema = 'name: string @index(exact) .'\nop = pydgraph.Operation(schema=schema)\nclient.alter(op)\n\n# Create a transaction and run a query\ntxn = client.txn(read_only=True)\nres = txn.query('{\"me\": function(func: eq(name, \"Alice\")) { name }}')\nprint(res.json)\ntxn.discard()\n\n# Close the stub\nclient_stub.close()","lang":"python","description":"Connect to a local Dgraph instance, set schema, query data."},"warnings":[{"fix":"Use `from pydgraph import DgraphClientStub` for the stub class.","message":"Using `from pydgraph import DgraphClientStub` is incorrect; the correct import is `from pydgraph import DgraphClientStub` (same) but note that `DgraphClientStub` is actually imported as `dgraph_client_stub` in some older docs. Actually the correct symbol is `DgraphClientStub` available directly.","severity":"gotcha","affected_versions":"all"},{"fix":"Always call `txn.discard()` in a finally block or use context manager (since v25.1.0).","message":"Transactions must be either committed or discarded; forgetting to discard a read-only transaction can lead to resource leaks.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `DgraphClientStub(api_endpoint)` directly or check cloud documentation.","message":"The `from_cloud` function (deprecated in v23.0.0) may not work with newer Dgraph Cloud endpoints; use `from_cloud` with caution.","severity":"gotcha","affected_versions":">=23.0.0"},{"fix":"Upgrade Dgraph server to v25.x or use an older pydgraph version (e.g., 24.3.0) with Dgraph v24.","message":"v25.0.0 updated to use Dgraph v25 API, which is incompatible with older Dgraph servers. Replaced RPC calls may cause connection failures.","severity":"breaking","affected_versions":">=25.0.0"}],"env_vars":null,"search_vec":"'25.2.0':12 '3.9':19 'api':16 'approxim':28 'cadenc':26 'client':4 'communic':24 'databas':10,31 'dgraph':6,14,32 'distribut':8 'graph':9,30 'grpc':22,33 'offici':2 'pydgraph':1 'python':3,18 'quarter':29 'releas':25 'requir':17 'support':13 'use':21 'v25':15 'version':11","created_at":"2026-05-01T08:12:25.030754+00:00","updated_at":"2026-05-01T08:12:25.030754+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"25.2.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://dgraph.io","github":"https://github.com/dgraph-io/pydgraph","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pydgraph/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}