From b04d5f09bf09837ab682114158d595ddd2d3dc6d Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 12 Mar 2024 22:37:48 +0800 Subject: [PATCH] Add Python requests example --- README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c4fc747..d0e85ee 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ For example: ```bash podman run -p 8000:8000 \ - -v /absolute/path/to/database:/database:U \ + -v path/to/database:/database:U \ --rm kuzudb/api-server:latest ``` @@ -89,7 +89,7 @@ or, ```bash podman run -p 8000:8000 \ - -v /absolute/path/to/database:/database \ + -v path/to/database:/database \ --userns=keep-id \ --rm kuzudb/api-server:latest ``` @@ -120,6 +120,14 @@ With `curl` in the terminal: curl http://localhost:8000 ``` +With `request` in Python: + +```python +import requests +response = requests.get("http://localhost:8000") +print(response.json()) +``` + #### Example response: ```json @@ -150,6 +158,14 @@ With `curl` in the terminal: curl http://localhost:8000/schema ``` +With `request` in Python: + +```python +import requests +response = requests.get("http://localhost:8000/schema") +print(response.json()) +``` + #### Example response: ```json @@ -248,6 +264,19 @@ curl -X POST\ http://localhost:8000/cypher ``` +With `request` in Python: + +```python +import requests +response = requests.post("http://localhost:8000/cypher", \ + json={ + "query": "MATCH (u:User) WHERE u.age > $a RETURN u", + "params": {"a": 25} + } + ) +print(response.json()) +``` + #### Example response: ```json