You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -40,85 +40,194 @@ The project uses [Poetry](https://python-poetry.org/) to build the GQLAlchemy Py
40
40
Before starting the tests, make sure you have an active Memgraph instance running. Execute the following command:
41
41
`poetry run pytest .`
42
42
43
-
## GQLAlchemy example
43
+
## GQLAlchemy capabilities
44
44
45
-
When working with the `gqlalchemy`, a Python developer can connect to the database and execute a `MATCH` Cypher query using the following syntax:
45
+
<details>
46
+
<summary>🗺️ Object graph mapper</summary>
47
+
<br>
48
+
49
+
Below you can see an example of how to create `User` and `Language` node classes, and a relationship class of type `SPEAKS`. Along with that, you can see how to create a new node and relationship and how to save them in the database. After that, you can load those nodes and relationship from the database.
50
+
<br>
51
+
<br>
52
+
53
+
```python
54
+
from gqlalchemy import Memgraph, Node, Relationship, Field
<summary>🗄️ Import table data from different sources</summary>
139
+
<br>
140
+
141
+
**Import table data to a graph database**
142
+
143
+
You can translate table data from a file to graph data and import it to Memgraph. Currently, we support reading of CSV, Parquet, ORC and IPC/Feather/Arrow file formats via the PyArrow package.
144
+
145
+
Read all about it in [table to graph importer how-to guide](https://memgraph.com/docs/gqlalchemy/how-to-guides/loaders/table-to-graph-importer).
70
146
71
-
memgraph = Memgraph()
147
+
**Make a custom file system importer**
72
148
73
-
results = (
74
-
match()
75
-
.node("Node", variable="from")
76
-
.to("Connection")
77
-
.node("Node", variable="to")
78
-
.return_()
79
-
.execute()
149
+
If you want to read from a file system not currently supported by GQLAlchemy, or use a file type currently not readable, you can implement your own by extending abstract classes `FileSystemHandler` and `DataLoader`, respectively.
150
+
151
+
Read all about it in [custom file system importer how-to guide](https://memgraph.com/docs/gqlalchemy/how-to-guides/loaders/custom-file-system-importer).
152
+
153
+
</details>
154
+
155
+
<details>
156
+
<summary>⚙️ Manage Memgraph instances</summary>
157
+
<br>
158
+
159
+
You can start, stop, connect to and monitor Memgraph instances with GQLAlchemy.
Because Memgraph supports database triggers on `CREATE`, `UPDATE` and `DELETE` operations, GQLAlchemy also implements a simple interface for maintaining these triggers.
97
196
197
+
```python
198
+
from gqlalchemy import Memgraph, MemgraphTrigger
199
+
from gqlalchemy.models import (
200
+
TriggerEventType,
201
+
TriggerEventObject,
202
+
TriggerExecutionPhase,
203
+
)
98
204
99
-
classFollows(Relationship, type="FOLLOWS"):
100
-
pass
205
+
db = Memgraph()
101
206
207
+
trigger = MemgraphTrigger(
208
+
name="ratings_trigger",
209
+
event_type=TriggerEventType.CREATE,
210
+
event_object=TriggerEventObject.NODE,
211
+
execution_phase=TriggerExecutionPhase.AFTER,
212
+
statement="UNWIND createdVertices AS node SET node.created_at = LocalDateTime()",
213
+
)
102
214
103
-
u1 = User(id=1).save(memgraph)
104
-
u2 = User(id=2).save(memgraph)
105
-
r = Follows(_start_node_id=u1._id, _end_node_id=u2._id).save(memgraph)
106
-
107
-
result =list(
108
-
match(memgraph.new_connection())
109
-
.node(variable="a")
110
-
.to(variable="r")
111
-
.node(variable="b")
112
-
.where("a.id", "=", u1.id)
113
-
.or_where("b.id", "=", u2.id)
114
-
.return_()
115
-
.execute()
116
-
)[0]
117
-
118
-
print(result["a"])
119
-
print(result["b"])
120
-
print(result["r"])
215
+
db.create_trigger(trigger)
216
+
triggers = db.get_triggers()
217
+
print(triggers)
121
218
```
219
+
</details>
220
+
221
+
<details>
222
+
<summary>💽 On-disk storage</summary>
223
+
<br>
224
+
225
+
Since Memgraph is an in-memory graph database, the GQLAlchemy library provides an on-disk storage solution for large properties not used in graph algorithms. This is useful when nodes or relationships have metadata that doesn’t need to be used in any of the graph algorithms that need to be carried out in Memgraph, but can be fetched after. Learn all about it in the [on-disk storage how-to guide](https://memgraph.com/docs/gqlalchemy/how-to-guides/on-disk-storage).
226
+
</details>
227
+
228
+
<br>
229
+
230
+
If you want to learn more about OGM, query builder, managing streams, importing data from different source, managing Memgraph instances, managing database triggers and using on-disk storage, check out the GQLAlchemy [how-to guides](https://memgraph.com/docs/gqlalchemy/how-to-guides).
0 commit comments