π TuringDB Python SDK
The TuringDB Python SDK provides an easy interface for connecting to your TuringDB Cloud instance, running queries, and managing graphs programmatically.π¦ Install the PythonSDK:Using
pip:
uv package manager (you will need to create a project first):
π Getting Started
π Need help with tokens or IDs? See Authentication Guide
π Initialization
- Uses secure HTTPX client
- Auth headers are set automatically
- API gateway refreshes every 60s β wait after creating a token or instance
π§ Core Methods
list_available_graphs() β list[str]
Returns all graphs you have access to on the TuringDB Cloud backend.
list_loaded_graphs() β list[str]
Returns the currently loaded graphs in memory.
create_graph(graph_name: str)
Creates a new empty graph with the specified name.
Internally executes CREATE GRAPH βgraph_nameβ
load_graph(graph_name: str, raise_if_loaded: bool = True)
Loads a previously created graph into memory.
raise_if_loaded=False, it will silently continue if the graph is already loaded.
query(query: str) β pandas.DataFrame
Runs a Cypher query on the current graph.
pandas.DataFrame, with automatic typing and parsing.
𧬠Version Control Helpers
TuringDB supports snapshot isolation and versioned commits. Use the following helpers to navigate graph history or work in isolated changes:checkout(change: int | str = "main", commit: str = "HEAD")
Switches the working context to a specific change or commit.
change: change ID or"main"commit: commit hash or"HEAD"
set_commit(commit: str)
Manually set the commit hash to use.
set_change(change: int | str)
Manually set the change ID to use (accepts int or hex string).
set_graph(graph_name: str)
Change the current graph context.
π Response Format
All queries return apandas.DataFrame, typed according to schema:
| Cypher Type | Python (NumPy) |
|---|---|
String | str |
Int64 | int64 |
UInt64 | uint64 |
Double | float64 |
Boolean | bool |
β οΈ Error Handling
All SDK errors raise a customTuringDBException.
π§ͺ Example Workflow
π§ Notes
- The SDK uses httpx for async-compatible HTTP requests
- Responses are parsed using
orjsonand converted intopandas.DataFramefor easy usage - Only graph name, change ID, and commit hash are sent with requests
- SDK supports full TuringDB Cypher dialect, including
@node injection,~=matching, and versioned queries

