Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions docs/1_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ pip install -e .

```python
import asyncio
from nebulagraph_python.client import NebulaAsyncClient
from nebulagraph_python.client import AsyncNebulaClient

async def main() -> None:
async with await NebulaAsyncClient.connect(
hosts=["127.0.0.1:9669"],
username="root",
password="NebulaGraph01",
) as client:
result = await client.execute("RETURN 1 AS a, 2 AS b")
result.print()
# Create async client
# Note: AsyncNebulaClient requires manual initialization
client = AsyncNebulaClient(
addresses="127.0.0.1:9669",
user_name="root",
password="nebula",
connect_timeout_ms=3000,
request_timeout_ms=30000
)

# Initialize the connection
await client._init_client()

result = await client.execute("RETURN 1 AS a, 2 AS b")
result.print()

asyncio.run(main())
```
Expand Down Expand Up @@ -116,7 +124,7 @@ from nebulagraph_python import NebulaClient

with NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
) as client:
result = client.execute("RETURN 1 AS a, 2 AS b")
Expand All @@ -134,7 +142,7 @@ from nebulagraph_python import NebulaClient

client = NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
)
try:
Expand All @@ -153,7 +161,7 @@ from nebulagraph_python.client import NebulaAsyncClient
async def main() -> None:
client = await NebulaAsyncClient.connect(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
)
try:
Expand Down
6 changes: 3 additions & 3 deletions docs/2_concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def concurrent_example():
# Create client with session pool for concurrency
async with await NebulaAsyncClient.connect(
hosts=["127.0.0.1:9669", "127.0.0.1:9670"], # Multiple hosts for HA
username="root",
user_name="root",
password="NebulaGraph01",
session_pool_config=SessionPoolConfig(
size=3, # Pool of 3 sessions per host
Expand Down Expand Up @@ -70,7 +70,7 @@ By default, statements run on a random session from the pool. When you need to r
async def contextual_example():
async with await NebulaAsyncClient.connect(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
session_pool_config=SessionPoolConfig(),
) as client:
Expand Down Expand Up @@ -148,7 +148,7 @@ from nebulagraph_python import NebulaClient, SessionPoolConfig

with NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
session_pool_config=SessionPoolConfig(), # enables multiple sessions per host
) as client, ThreadPoolExecutor(max_workers=8) as executor:
Expand Down
2 changes: 1 addition & 1 deletion docs/3_templating_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from nebulagraph_python.client import NebulaAsyncClient
async def main() -> None:
async with await NebulaAsyncClient.connect(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
) as client:
query = """
Expand Down
4 changes: 2 additions & 2 deletions docs/4_error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ The relevant definitions live in the `nebulagraph_python.error` module.

```python
import asyncio
from nebulagraph_python.client.client import NebulaAsyncClient
from nebulagraph_python.client.nebula_client import NebulaAsyncClient
from nebulagraph_python.error import NebulaGraphRemoteError, ErrorCode

async def main():
async with await NebulaAsyncClient.connect(
hosts="localhost:9669", username="root", password="NebulaGraph01"
hosts="localhost:9669", user_name="root", password="NebulaGraph01"
) as client:
try:
rs = await client.execute_py("USE not_exist_graph RETURN 1")
Expand Down
8 changes: 4 additions & 4 deletions docs/5_vector_and_special_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ API:

Examples:
```python
from nebulagraph_python.client.client import NebulaClient
from nebulagraph_python.client.nebula_client import NebulaClient
from nebulagraph_python.py_data_types import NVector

# Connect (adjust hosts/credentials to your environment)
cli = NebulaClient(hosts=["127.0.0.1:9669"], username="root", password="NebulaGraph01")
cli = NebulaClient(hosts=["127.0.0.1:9669"], user_name="root", password="NebulaGraph01")

# RETURN a vector and read it from the result
res = cli.execute_py("RETURN vector<3, float>([1, 2, 3]) AS vec")
Expand Down Expand Up @@ -70,10 +70,10 @@ API:

Examples:
```python
from nebulagraph_python.client.client import NebulaClient
from nebulagraph_python.client.nebula_client import NebulaClient
from nebulagraph_python.py_data_types import NDuration

cli = NebulaClient(hosts=["127.0.0.1:9669"], username="root", password="Nebula.123")
cli = NebulaClient(hosts=["127.0.0.1:9669"], user_name="root", password="Nebula.123")

# RETURN a duration literal from the server and read it
# Adjust the literal to your NebulaGraph version if needed
Expand Down
24 changes: 15 additions & 9 deletions docs/6_scan_all.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ This guide shows how to iterate through every node and edge type in a graph and
### Example: scan everything in a space

```python
from nebulagraph_python.client import NebulaClient, SessionConfig
from nebulagraph_python.orm import get_graph_type
from nebulagraph_python.client import NebulaClient
from nebulagraph_python.tools import scan_edges, scan_nodes
from nebulagraph_python.tools.get_graph_type import get_graph_type
from nebulagraph_python.tools.session_conf import get_graph_type_name


# Create client
client = NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
password="NebulaGraph01",
session_config=SessionConfig(
graph="movie",
),
addresses="127.0.0.1:9669",
user_name="root",
password="nebula",
connect_timeout_ms=3000,
request_timeout_ms=30000,
)

# Discover schema metadata for the target graph
graph_type = get_graph_type(client, graph_name="movie")
graph_type_name = get_graph_type_name(client, graph_name="movie")
graph_type = get_graph_type(client, graph_type_name=graph_type_name)

# Scan all nodes (by type)
for node_type_name, node_type in graph_type.nodes.items():
Expand All @@ -50,9 +52,13 @@ for edge_type_name, edge_type in graph_type.edges.items():
)
):
print("edge", edge_type_name, count, src, edge, dst)

# Close the client
client.close()
```

### Notes
- **`properties_list`**: provide the properties you want to fetch. Using `list(node_type.properties.keys())` pulls all properties for that type.
- **`batch_size`**: controls page size when scanning nodes; tune it based on data volume and memory.
- The edge scan yields tuples `(src, edge, dst)` describing the full relation.
- Remember to close the client when done to release resources.
2 changes: 1 addition & 1 deletion docs/7_orm.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ from nebulagraph_python.py_data_types import NVector

client = NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
session_config=SessionConfig(graph="movie"),
)
Expand Down
2 changes: 1 addition & 1 deletion docs/7_orm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Create client
client = NebulaClient(
hosts=["127.0.0.1:9669"],
username="root",
user_name="root",
password="NebulaGraph01",
session_config=SessionConfig(
graph="movie",
Expand Down
Loading