Skip to content

Commit ad788c9

Browse files
committed
Update missing docs.
1 parent cc5221b commit ad788c9

4 files changed

Lines changed: 222 additions & 63 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# How to manage Memgraph database
2+
3+
Through this guide, you will learn how to use GQLAlchemy to manage your Memgraph database instance:
4+
5+
- [How to manage Memgraph database](#how-to-manage-memgraph-database)
6+
- [Get storage information](#get-storage-information)
7+
- [Get build information](#get-build-information)
8+
- [Analyze graph statistics](#analyze-graph-statistics)
9+
- [Analyze all labels](#analyze-all-labels)
10+
- [Analyze specific labels](#analyze-specific-labels)
11+
- [Delete graph statistics](#delete-graph-statistics)
12+
- [Delete statistics for specific labels](#delete-statistics-for-specific-labels)
13+
14+
>If you have any more questions, join our community and ping us on [Discord](https://discord.gg/memgraph).
15+
16+
!!! info
17+
To use the features below, you must [install GQLAlchemy](../installation.md) and have a running Memgraph instance. If you're unsure how to run Memgraph, check out the Memgraph [Quick start](https://memgraph.com/docs/getting-started)).
18+
19+
## Get storage information
20+
21+
To retrieve **detailed storage information** about your Memgraph instance, use the [`get_storage_info()`](../reference/gqlalchemy/vendors/memgraph.md#get_storage_info) method. It returns information such as vertex count, edge count, memory usage, and disk usage.
22+
23+
```python
24+
from gqlalchemy import Memgraph
25+
26+
db = Memgraph()
27+
28+
storage_info = db.get_storage_info()
29+
for item in storage_info:
30+
print(item)
31+
```
32+
33+
## Get build information
34+
35+
To retrieve **build information** about the running Memgraph instance, use the [`get_build_info()`](../reference/gqlalchemy/vendors/memgraph.md#get_build_info) method. It returns information such as the build type (optimization level).
36+
37+
```python
38+
from gqlalchemy import Memgraph
39+
40+
db = Memgraph()
41+
42+
build_info = db.get_build_info()
43+
for item in build_info:
44+
print(item)
45+
```
46+
47+
## Analyze graph statistics
48+
49+
Memgraph can analyze the graph to calculate statistics that help it select more optimal indexes and speed up `MERGE` operations. Use the [`analyze_graph()`](../reference/gqlalchemy/vendors/memgraph.md#analyze_graph) and [`delete_graph_statistics()`](../reference/gqlalchemy/vendors/memgraph.md#delete_graph_statistics) methods to manage these statistics.
50+
51+
### Analyze all labels
52+
53+
To **analyze statistics for all labels** in the graph:
54+
55+
```python
56+
from gqlalchemy import Memgraph
57+
58+
db = Memgraph()
59+
60+
results = db.analyze_graph()
61+
for result in results:
62+
print(result)
63+
```
64+
65+
The result includes information about each indexed label-property pair: label, property, number of estimation nodes, number of groups, average group size, chi-squared value, and average degree.
66+
67+
### Analyze specific labels
68+
69+
To **analyze statistics only for specific labels**:
70+
71+
```python
72+
from gqlalchemy import Memgraph
73+
74+
db = Memgraph()
75+
76+
results = db.analyze_graph(labels=["Person", "City"])
77+
for result in results:
78+
print(result)
79+
```
80+
81+
### Delete graph statistics
82+
83+
To **delete all previously calculated graph statistics**:
84+
85+
```python
86+
from gqlalchemy import Memgraph
87+
88+
db = Memgraph()
89+
90+
deleted = db.delete_graph_statistics()
91+
for item in deleted:
92+
print(item)
93+
```
94+
95+
### Delete statistics for specific labels
96+
97+
To **delete statistics for specific labels only**:
98+
99+
```python
100+
from gqlalchemy import Memgraph
101+
102+
db = Memgraph()
103+
104+
deleted = db.delete_graph_statistics(labels=["Person"])
105+
for item in deleted:
106+
print(item)
107+
```
108+
109+
>Hopefully, this guide has taught you how to manage your Memgraph database using GQLAlchemy. If you
110+
>have any more questions, join our community and ping us on [Discord](https://discord.gg/memgraph).

docs/how-to-guides/overview.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ certain algorithm.
7474

7575
- [**Create a graph projection**](query-builder/graph-projection.md)
7676

77+
## Manage Memgraph database
78+
79+
GQLAlchemy provides methods for managing and inspecting your Memgraph database
80+
instance, including retrieving storage and build information, and analyzing graph
81+
statistics for index optimization.
82+
83+
- [**Manage Memgraph database**](manage-database.md)
84+
7785
## Transform Python graphs into Memgraph graphs
7886

7987
GQLAlchemy holds transformations that can transform NetworkX, PyG and DGL graphs

docs/how-to-guides/query-builder.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Through this guide, you will learn how to use the GQLAlchemy query builder to:
1919
- [**Filter data**](#filter-data)
2020
- [**Filter data by property comparison**](#filter-data-by-property-comparison)
2121
- [**Filter data by property value**](#filter-data-by-property-value)
22+
- [**Filter data with the IN operator**](#filter-data-with-the-in-operator)
2223
- [**Filter data by label**](#filter-data-by-label)
2324
- [**Return results**](#return-results)
2425
- [**Return all variables from a query**](#return-all-variables-from-a-query)
@@ -705,6 +706,45 @@ MATCH (p:Person) WHERE p.age > 18 OR p.name = "John" RETURN *;
705706
The `literal` keyword is used again since you want `John` to be quoted in the
706707
Cypher query (to be saved as a string in the database).
707708

709+
### Filter data with the IN operator
710+
711+
You can use the `IN` operator to **check if a property value is contained in a list** of values.
712+
713+
<Tabs
714+
defaultValue="gqlalchemy"
715+
values={[
716+
{label: 'GQLAlchemy', value: 'gqlalchemy'},
717+
{label: 'Cypher', value: 'cypher'}
718+
]}>
719+
<TabItem value="gqlalchemy">
720+
721+
```python
722+
from gqlalchemy import match
723+
from gqlalchemy.query_builders.memgraph_query_builder import Operator
724+
725+
results = list(
726+
match()
727+
.node(labels="Person", variable="p")
728+
.where(item="p.name", operator=Operator.IN, literal=["Alice", "Bob"])
729+
.return_()
730+
.execute()
731+
)
732+
733+
print(results)
734+
```
735+
736+
</TabItem>
737+
<TabItem value="cypher">
738+
739+
```cypher
740+
MATCH (p:Person) WHERE p.name IN ["Alice", "Bob"] RETURN *;
741+
```
742+
743+
</TabItem>
744+
</Tabs>
745+
746+
The `literal` keyword argument is used because you want list values to be properly quoted in the Cypher query. You can also combine `IN` with other boolean operators like `AND`, `OR`, etc.
747+
708748
### Filter data by label
709749

710750
Nodes can be filtered by their label using the `WHERE` clause instead of

mkdocs.yml

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,84 @@
1-
21
site_name: GQLAlchemy Documentation
32

43
markdown_extensions:
5-
- admonition
6-
- pymdownx.details
7-
- pymdownx.superfences
4+
- admonition
5+
- pymdownx.details
6+
- pymdownx.superfences
87

98
theme:
109
name: 'material'
1110
logo: 'assets/memgraph-logo.svg'
1211
font:
1312
text: 'Roboto'
14-
code: 'Roboto Mono'
13+
code: 'Roboto Mono'
1514
icon:
1615
repo: fontawesome/brands/github
1716
palette:
1817
primary: 'custom'
1918
accent: 'custom'
2019

2120
nav:
22-
- Getting Started: 'index.md'
23-
- Installation: 'installation.md'
24-
- Import data: 'import-data.md'
25-
- How-to guides:
26-
- Overview: 'how-to-guides/overview.md'
27-
- Use object graph mapper: 'how-to-guides/ogm.md'
28-
- Use query builder: 'how-to-guides/query-builder.md'
29-
- Manage streams:
30-
- Kafka streams: 'how-to-guides/streams/kafka-streams.md'
31-
- Pulsar streams: 'how-to-guides/streams/pulsar-streams.md'
32-
- Import data from different sources:
33-
- Import table data as a graph: 'how-to-guides/loaders/import-table-data-to-graph-database.md'
34-
- Make a custom file system importer: 'how-to-guides/loaders/make-a-custom-file-system-importer.md'
35-
- Manage instances:
36-
- Manage Memgraph Docker instances: 'how-to-guides/instance-runner/memgraph-docker-instance.md'
37-
- Manage Memgraph binary instances: 'how-to-guides/instance-runner/memgraph-binary-instance.md'
38-
- Manage database triggers: 'how-to-guides/triggers/triggers.md'
39-
- Use on-disk storage: 'how-to-guides/on-disk-storage/on-disk-storage.md'
40-
- Create a graph projection: 'how-to-guides/query-builder/graph-projection.md'
41-
- Translate Python graphs:
42-
- Import Python graphs into Memgraph: 'how-to-guides/translators/import-python-graphs.md'
43-
- Export data from Memgraph into Python graphs: 'how-to-guides/translators/export-python-graphs.md'
44-
- Reference:
45-
- Overview: 'reference/gqlalchemy/overview.md'
46-
- graph_algorithms:
47-
- integrated_algorithms: 'reference/gqlalchemy/graph_algorithms/integrated_algorithms.md'
48-
- query_builder: 'reference/gqlalchemy/graph_algorithms/query_builder.md'
49-
- query_modules: 'reference/gqlalchemy/graph_algorithms/query_modules.md'
50-
- query_builders:
51-
- declarative_base: 'reference/gqlalchemy/query_builders/declarative_base.md'
52-
- memgraph_query_builder: 'reference/gqlalchemy/query_builders/memgraph_query_builder.md'
53-
- transformations:
54-
- transformations.export:
55-
- graph_transporter: 'reference/gqlalchemy/transformations/export/graph_transporter.md'
56-
- transporter: 'reference/gqlalchemy/transformations/export/transporter.md'
57-
- transformations.importing:
58-
- graph_importer: 'reference/gqlalchemy/transformations/importing/graph_importer.md'
59-
- loaders: 'reference/gqlalchemy/transformations/importing/loaders.md'
60-
- transformations.translators:
61-
- dgl_translator: 'reference/gqlalchemy/transformations/translators/dgl_translator.md'
62-
- nx_translator: 'reference/gqlalchemy/transformations/translators/nx_translator.md'
63-
- pyg_translator: 'reference/gqlalchemy/transformations/translators/pyg_translator.md'
64-
- translator: 'reference/gqlalchemy/transformations/translators/translator.md'
65-
- vendors:
66-
- database_client: 'reference/gqlalchemy/vendors/database_client.md'
67-
- memgraph: 'reference/gqlalchemy/vendors/memgraph.md'
68-
- neo4j: 'reference/gqlalchemy/vendors/neo4j.md'
69-
- connection: 'reference/gqlalchemy/connection.md'
70-
- disk_storage: 'reference/gqlalchemy/disk_storage.md'
71-
- exceptions: 'reference/gqlalchemy/exceptions.md'
72-
- instance_runner: 'reference/gqlalchemy/instance_runner.md'
73-
- models: 'reference/gqlalchemy/models.md'
74-
- utilities: 'reference/gqlalchemy/utilities.md'
75-
- Under the Hood:
76-
- Overview: 'under-the-hood/overview.md'
77-
- Python graph translators: 'under-the-hood/python-graph-translators.md'
78-
- Changelog: 'changelog.md'
21+
- Getting Started: 'index.md'
22+
- Installation: 'installation.md'
23+
- Import data: 'import-data.md'
24+
- How-to guides:
25+
- Overview: 'how-to-guides/overview.md'
26+
- Use object graph mapper: 'how-to-guides/ogm.md'
27+
- Use query builder: 'how-to-guides/query-builder.md'
28+
- Manage streams:
29+
- Kafka streams: 'how-to-guides/streams/kafka-streams.md'
30+
- Pulsar streams: 'how-to-guides/streams/pulsar-streams.md'
31+
- Import data from different sources:
32+
- Import table data as a graph: 'how-to-guides/loaders/import-table-data-to-graph-database.md'
33+
- Make a custom file system importer: 'how-to-guides/loaders/make-a-custom-file-system-importer.md'
34+
- Manage instances:
35+
- Manage Memgraph Docker instances: 'how-to-guides/instance-runner/memgraph-docker-instance.md'
36+
- Manage Memgraph binary instances: 'how-to-guides/instance-runner/memgraph-binary-instance.md'
37+
- Manage database triggers: 'how-to-guides/triggers/triggers.md'
38+
- Use on-disk storage: 'how-to-guides/on-disk-storage/on-disk-storage.md'
39+
- Create a graph projection: 'how-to-guides/query-builder/graph-projection.md'
40+
- Manage Memgraph database: 'how-to-guides/manage-database.md'
41+
- Translate Python graphs:
42+
- Import Python graphs into Memgraph: 'how-to-guides/translators/import-python-graphs.md'
43+
- Export data from Memgraph into Python graphs: 'how-to-guides/translators/export-python-graphs.md'
44+
- Reference:
45+
- Overview: 'reference/gqlalchemy/overview.md'
46+
- graph_algorithms:
47+
- integrated_algorithms: 'reference/gqlalchemy/graph_algorithms/integrated_algorithms.md'
48+
- query_builder: 'reference/gqlalchemy/graph_algorithms/query_builder.md'
49+
- query_modules: 'reference/gqlalchemy/graph_algorithms/query_modules.md'
50+
- query_builders:
51+
- declarative_base: 'reference/gqlalchemy/query_builders/declarative_base.md'
52+
- memgraph_query_builder: 'reference/gqlalchemy/query_builders/memgraph_query_builder.md'
53+
- transformations:
54+
- transformations.export:
55+
- graph_transporter: 'reference/gqlalchemy/transformations/export/graph_transporter.md'
56+
- transporter: 'reference/gqlalchemy/transformations/export/transporter.md'
57+
- transformations.importing:
58+
- graph_importer: 'reference/gqlalchemy/transformations/importing/graph_importer.md'
59+
- loaders: 'reference/gqlalchemy/transformations/importing/loaders.md'
60+
- transformations.translators:
61+
- dgl_translator: 'reference/gqlalchemy/transformations/translators/dgl_translator.md'
62+
- nx_translator: 'reference/gqlalchemy/transformations/translators/nx_translator.md'
63+
- pyg_translator: 'reference/gqlalchemy/transformations/translators/pyg_translator.md'
64+
- tfgnn_translator: 'reference/gqlalchemy/transformations/translators/tfgnn_translator.md'
65+
- translator: 'reference/gqlalchemy/transformations/translators/translator.md'
66+
- vendors:
67+
- database_client: 'reference/gqlalchemy/vendors/database_client.md'
68+
- memgraph: 'reference/gqlalchemy/vendors/memgraph.md'
69+
- neo4j: 'reference/gqlalchemy/vendors/neo4j.md'
70+
- connection: 'reference/gqlalchemy/connection.md'
71+
- disk_storage: 'reference/gqlalchemy/disk_storage.md'
72+
- exceptions: 'reference/gqlalchemy/exceptions.md'
73+
- instance_runner: 'reference/gqlalchemy/instance_runner.md'
74+
- models: 'reference/gqlalchemy/models.md'
75+
- utilities: 'reference/gqlalchemy/utilities.md'
76+
- Under the Hood:
77+
- Overview: 'under-the-hood/overview.md'
78+
- Python graph translators: 'under-the-hood/python-graph-translators.md'
79+
- Changelog: 'changelog.md'
7980

8081
repo_name: 'memgraph/gqlalchemy'
8182
repo_url: 'https://github.com/memgraph/gqlalchemy'
8283
extra_css:
83-
- stylesheets/extra.css
84+
- stylesheets/extra.css

0 commit comments

Comments
 (0)