Skip to content

Commit f6642d0

Browse files
authored
Merge pull request #136 from FalkorDB/graph-copy
add python copy example
2 parents 30f13e5 + 78c3fde commit f6642d0

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

commands/graph.copy.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ parent: "Commands"
99

1010
Usage: `GRAPH.COPY <src> <dest>`
1111

12-
The `GRAPH.COPY` command creates a copy of a graph, while the copy is performed
13-
the `src` graph is fully accessible.
12+
The GRAPH.COPY command creates a copy of a graph while leaving the source graph fully accessible.
1413

1514
Example:
16-
```
17-
127.0.0.1:6379> keys *
15+
16+
{% capture shell_0 %}
17+
127.0.0.1:6379> GRAPH.LIST
1818
(empty array)
1919
127.0.0.1:6379> GRAPH.QUERY A "CREATE (:Account {number: 516637})"
2020
1) 1) "Labels added: 1"
@@ -24,7 +24,7 @@ Example:
2424
5) "Query internal execution time: 0.588084 milliseconds"
2525
127.0.0.1:6379> GRAPH.COPY A Z
2626
"OK"
27-
127.0.0.1:6379> keys *
27+
127.0.0.1:6379> GRAPH.LIST
2828
1) "Z"
2929
2) "telemetry{A}"
3030
3) "A"
@@ -33,4 +33,24 @@ Example:
3333
2) 1) 1) (integer) 516637
3434
3) 1) "Cached execution: 0"
3535
2) "Query internal execution time: 0.638375 milliseconds"
36-
```
36+
{% endcapture %}
37+
38+
{% capture python_0 %}
39+
# Graphs list is empty
40+
graph_list = db.list()
41+
42+
# Create Graph 'A'
43+
graph_a = db.select_graph('A')
44+
result = graph_a.query('CREATE (:Account {number: 516637})')
45+
46+
# Copy Graph 'A' to 'Z'
47+
graph_z = graph_a.copy('Z')
48+
49+
# Graphs list including 'A' and 'Z'
50+
graph_list = db.list()
51+
52+
# Query Graph 'Z'
53+
result = graph_z.query('MATCH (a:Account) RETURN a.number')
54+
{% endcapture %}
55+
56+
{% include code_tabs.html id="tabs_0" shell=shell_0 python=python_0 %}

0 commit comments

Comments
 (0)