Skip to content

Commit 07f2981

Browse files
authored
Update reference guide (#241)
* Update reference guide * Update CODEOWNERS
1 parent 367f2ca commit 07f2981

24 files changed

Lines changed: 1610 additions & 87 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @Josipmrden @katarinasupe @brunos252 @as51340
1+
* @Josipmrden @katarinasupe @brunos252 @as51340 @antepusic
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
sidebar_label: connection
3+
title: gqlalchemy.connection
4+
---
5+
6+
## Connection Objects
7+
8+
```python
9+
class Connection(ABC)
10+
```
11+
12+
#### execute
13+
14+
```python
15+
@abstractmethod
16+
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
17+
```
18+
19+
Executes Cypher query without returning any results.
20+
21+
#### execute\_and\_fetch
22+
23+
```python
24+
@abstractmethod
25+
def execute_and_fetch(
26+
query: str,
27+
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
28+
```
29+
30+
Executes Cypher query and returns iterator of results.
31+
32+
#### is\_active
33+
34+
```python
35+
@abstractmethod
36+
def is_active() -> bool
37+
```
38+
39+
Returns True if connection is active and can be used.
40+
41+
## MemgraphConnection Objects
42+
43+
```python
44+
class MemgraphConnection(Connection)
45+
```
46+
47+
#### execute
48+
49+
```python
50+
@database_error_handler
51+
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
52+
```
53+
54+
Executes Cypher query without returning any results.
55+
56+
#### execute\_and\_fetch
57+
58+
```python
59+
@database_error_handler
60+
def execute_and_fetch(
61+
query: str,
62+
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
63+
```
64+
65+
Executes Cypher query and returns iterator of results.
66+
67+
#### is\_active
68+
69+
```python
70+
def is_active() -> bool
71+
```
72+
73+
Returns True if connection is active and can be used.
74+
75+
## Neo4jConnection Objects
76+
77+
```python
78+
class Neo4jConnection(Connection)
79+
```
80+
81+
#### execute
82+
83+
```python
84+
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
85+
```
86+
87+
Executes Cypher query without returning any results.
88+
89+
#### execute\_and\_fetch
90+
91+
```python
92+
def execute_and_fetch(
93+
query: str,
94+
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
95+
```
96+
97+
Executes Cypher query and returns iterator of results.
98+
99+
#### is\_active
100+
101+
```python
102+
def is_active() -> bool
103+
```
104+
105+
Returns True if connection is active and can be used.
106+

docs/reference/gqlalchemy/disk_storage.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,53 @@ An abstract class for implementing on-disk storage features with specific databa
1414
#### save\_node\_property
1515

1616
```python
17-
def save_node_property(node_id: int, property_name: str, property_value: str) -> None
17+
def save_node_property(node_id: int, property_name: str,
18+
property_value: str) -> None
1819
```
1920

2021
Saves a node property to an on disk database.
2122

2223
#### load\_node\_property
2324

2425
```python
25-
def load_node_property(node_id: int, property_name: str, property_value: str) -> Optional[str]
26+
def load_node_property(node_id: int, property_name: str,
27+
property_value: str) -> Optional[str]
2628
```
2729

2830
Loads a node property from an on disk database.
2931

3032
#### delete\_node\_property
3133

3234
```python
33-
def delete_node_property(node_id: int, property_name: str, property_value: str) -> None
35+
def delete_node_property(node_id: int, property_name: str,
36+
property_value: str) -> None
3437
```
3538

3639
Deletes a node property from an on disk database.
3740

3841
#### save\_relationship\_property
3942

4043
```python
41-
def save_relationship_property(relationship_id: int, property_name: str, property_value: str) -> None
44+
def save_relationship_property(relationship_id: int, property_name: str,
45+
property_value: str) -> None
4246
```
4347

4448
Saves a relationship property to an on disk database.
4549

4650
#### load\_relationship\_property
4751

4852
```python
49-
def load_relationship_property(relationship_id: int, property_name: str, property_value: str) -> Optional[str]
53+
def load_relationship_property(relationship_id: int, property_name: str,
54+
property_value: str) -> Optional[str]
5055
```
5156

5257
Loads a relationship property from an on disk database.
5358

5459
#### delete\_relationship\_property
5560

5661
```python
57-
def delete_relationship_property(node_id: int, property_name: str, property_value: str) -> None
62+
def delete_relationship_property(node_id: int, property_name: str,
63+
property_value: str) -> None
5864
```
5965

6066
Deletes a node property from an on disk database.
@@ -101,7 +107,8 @@ Deletes all properties in the database.
101107
#### save\_node\_property
102108

103109
```python
104-
def save_node_property(node_id: int, property_name: str, property_value: str) -> None
110+
def save_node_property(node_id: int, property_name: str,
111+
property_value: str) -> None
105112
```
106113

107114
Saves a node property to an on disk database.
@@ -146,7 +153,8 @@ Deletes a node property from an on disk database.
146153
#### save\_relationship\_property
147154

148155
```python
149-
def save_relationship_property(relationship_id: int, property_name: str, property_value: str) -> None
156+
def save_relationship_property(relationship_id: int, property_name: str,
157+
property_value: str) -> None
150158
```
151159

152160
Saves a relationship property to an on disk database.
@@ -160,7 +168,8 @@ Saves a relationship property to an on disk database.
160168
#### load\_relationship\_property
161169

162170
```python
163-
def load_relationship_property(relationship_id: int, property_name: str) -> Optional[str]
171+
def load_relationship_property(relationship_id: int,
172+
property_name: str) -> Optional[str]
164173
```
165174

166175
Loads a relationship property from an on disk database.
@@ -178,7 +187,8 @@ Loads a relationship property from an on disk database.
178187
#### delete\_relationship\_property
179188

180189
```python
181-
def delete_relationship_property(relationship_id: int, property_name: str) -> None
190+
def delete_relationship_property(relationship_id: int,
191+
property_name: str) -> None
182192
```
183193

184194
Deletes a node property from an on disk database.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
sidebar_label: exceptions
3+
title: gqlalchemy.exceptions
4+
---
5+
6+
#### connection\_handler
7+
8+
```python
9+
def connection_handler(func,
10+
delay: float = 0.01,
11+
timeout: float = 5.0,
12+
backoff: int = 2)
13+
```
14+
15+
Wrapper for a wait on the connection.
16+
17+
**Arguments**:
18+
19+
- `func` - A function that tries to create the connection
20+
- `delay` - A float that defines how long to wait between retries.
21+
- `timeout` - A float that defines how long to wait for the port.
22+
- `backoff` - An integer used for multiplying the delay.
23+
24+
25+
**Raises**:
26+
27+
- `GQLAlchemyWaitForConnectionError` - Raises an error
28+
after the timeout period has passed.
29+

docs/reference/gqlalchemy/graph_algorithms/integrated_algorithms.md

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ lambda.
6363
#### \_\_init\_\_
6464

6565
```python
66-
def __init__(lower_bound: int = None, upper_bound: int = None, condition: str = None) -> None
66+
def __init__(lower_bound: int = None,
67+
upper_bound: int = None,
68+
condition: str = None) -> None
6769
```
6870

6971
**Arguments**:
7072

71-
- `lower_bound` - Lower bound for path depth. Defaults to `None`.
72-
- `upper_bound` - Upper bound for path depth. Defaults to `None`.
73+
- `lower_bound` - Lower bound for path depth.
74+
- `upper_bound` - Upper bound for path depth.
7375
- `condition` - Filter through nodes and relationships that pass this
74-
condition. Defaults to `None`.
76+
condition.
7577

7678
#### \_\_str\_\_
7779

@@ -107,15 +109,17 @@ lambda.
107109
#### \_\_init\_\_
108110

109111
```python
110-
def __init__(lower_bound: int = None, upper_bound: int = None, condition: str = None) -> None
112+
def __init__(lower_bound: int = None,
113+
upper_bound: int = None,
114+
condition: str = None) -> None
111115
```
112116

113117
**Arguments**:
114118

115-
- `lower_bound` - Lower bound for path depth. Defaults to None.
116-
- `upper_bound` - Upper bound for path depth. Defaults to None.
119+
- `lower_bound` - Lower bound for path depth.
120+
- `upper_bound` - Upper bound for path depth.
117121
- `condition` - Filter through nodes and relationships that pass this
118-
condition. Defaults to None.
122+
condition.
119123

120124
#### \_\_str\_\_
121125

@@ -139,7 +143,8 @@ If bounds are specified, returns them in grammar-defined form.
139143
class WeightedShortestPath(IntegratedAlgorithm)
140144
```
141145

142-
Build a Djikstra shortest path call for a Cypher query
146+
Build a Djikstra shortest path call for a Cypher query.
147+
143148
The weighted shortest path algorithm can be called in Memgraph with Cypher
144149
queries such as:
145150
" MATCH (a {id: 723})-[r *WSHORTEST 10 (r, n | r.weight) weight_sum
@@ -151,16 +156,52 @@ is a filter lambda, used to filter which relationships and nodes to use.
151156
#### \_\_init\_\_
152157

153158
```python
154-
def __init__(upper_bound: int = None, condition: str = None, total_weight_var: str = DEFAULT_TOTAL_WEIGHT, weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
159+
def __init__(upper_bound: int = None,
160+
condition: str = None,
161+
total_weight_var: str = DEFAULT_TOTAL_WEIGHT,
162+
weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
163+
```
164+
165+
**Arguments**:
166+
167+
- `upper_bound` - Upper bound for path depth.
168+
- `condition` - Filter through nodes and relationships that pass this
169+
condition.
170+
- `total_weight_var` - Variable defined as the sum of all weights on
171+
path being returned.
172+
- `weight_property` - property being used as weight.
173+
174+
## AllShortestPath Objects
175+
176+
```python
177+
class AllShortestPath(IntegratedAlgorithm)
178+
```
179+
180+
Build a Djikstra shortest path call for a Cypher query.
181+
182+
The weighted shortest path algorithm can be called in Memgraph with Cypher
183+
queries such as:
184+
" MATCH (a {id: 723})-[r *ALLSHORTEST 10 (r, n | r.weight) total_weight
185+
(r, n | r.x > 12 AND r.y < 3)]-(b {id: 882}) RETURN * "
186+
It is called inside the relationship clause, "*ALLSHORTEST" naming the
187+
algorithm, "10" specifying search depth bounds, and "(r, n | <expression>)"
188+
is a filter lambda, used to filter which relationships and nodes to use.
189+
190+
#### \_\_init\_\_
191+
192+
```python
193+
def __init__(upper_bound: int = None,
194+
condition: str = None,
195+
total_weight_var: str = DEFAULT_TOTAL_WEIGHT,
196+
weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
155197
```
156198

157199
**Arguments**:
158200

159-
- `upper_bound` - Upper bound for path depth. Defaults to None.
201+
- `upper_bound` - Upper bound for path depth.
160202
- `condition` - Filter through nodes and relationships that pass this
161-
condition. Defaults to None.
203+
condition.
162204
- `total_weight_var` - Variable defined as the sum of all weights on
163-
path being returned. Defaults to "total_weight".
164-
- `weight_property` - property being used as weight. Defaults to
165-
"r.weight".
205+
path being returned.
206+
- `weight_property` - Property being used as weight.
166207

docs/reference/gqlalchemy/graph_algorithms/query_modules.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ method.
4343
#### parse\_query\_module\_signature
4444

4545
```python
46-
def parse_query_module_signature(signature: str) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]
46+
def parse_query_module_signature(
47+
signature: str) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]
4748
```
4849

4950
Query Modules signatures received from Memgraph are parsed into a
@@ -67,7 +68,11 @@ type of argument and "default" where default argument value is given
6768
#### parse\_field
6869

6970
```python
70-
def parse_field(vars_field: str, name_type_delimiter: str = NAME_TYPE_DELIMITIER, default_value_delimiter: str = EQUALS_DELIMITER) -> List[Dict[str, str]]
71+
def parse_field(
72+
vars_field: str,
73+
name_type_delimiter: str = NAME_TYPE_DELIMITIER,
74+
default_value_delimiter: str = EQUALS_DELIMITER
75+
) -> List[Dict[str, str]]
7176
```
7277

7378
Parse a field of arguments or returns from Query Module signature.

0 commit comments

Comments
 (0)