neo4j-meta-logger
A python module to log and track your neo4j graph schema transformations.
call db.schema.visualization + ⏲️ a time machine + some helpful 🔧 tools and 📈 statistics
Works fast with neo4j graphs of any size 💪
Maintainer: Tim Bleimehl
Status: Pre-alpha
Example
Lets create a sample graph with python and Neo4J
import py2neo
from NeoMetaTracker import NeoMetaTracker
g = py2neo.Graph(name="test_graph")
g.run(
"CREATE p = (:Human{name:'Amina Okujewa'})-[:LIVES_ON]->(:World {name: 'Earth'})"
)
g.run(
"CREATE p = (:Cat{name:'Grumpy Cat'})-[:LIVES_ON]->(:World {name: 'Internet'})"
)
g.run(
"MATCH (wI:World{name:'Internet'}),(wE:World{name:'Earth'}) CREATE (wI)-[:EXISTS_ON]->(wE)"
)
Our graph looks like this:
and the schema will look like this:
Lets capture the current status to analyse the changes later.
meta_logger = NeoMetaTracker(test_graph)
meta_logger.capture()
Now lets do some changes to our Graphs content
g.run(
"MATCH (wI:World{name:'Internet'}),(wE:World{name:'Earth'}) CREATE (as:Human{name:'Aaron Swartz'})-[:LIVES_ON]->(wI), (as)-[:LIVES_ON]->(wE)"
)
Our graph now looks like this
The schema still looks the same. We wont be able to recognize changes without any help:
call db.schema.visualization
Here come NeoMetaTracker for the rescue
Lets do another capture to compare the changes we did:
meta_logger.capture()
Now we can analyze the changes in the graph:
meta_logger.get_numeric_last_changes()
This outputs:
{'labels': {'Human': 1}, 'relations': {'LIVES_ON': 2}}
We can see we created one new Node with the Label Human and 2 new relations named LIVES_ON.
This allready can be a valuable meta information, but wait there is more...
Lets visualize the schema changes in another graph.
changes_subgraph = meta_logger.get_schemagraph_last_changes()
schema_g = py2neo.Graph(name="test_graph")
schema_g.merge(changes_subgraph)
Now we only see the part of our schema that changed:
We can also recall any old state of our schema on any point in time where we did a capture
meta_logger.capture_points[0].schema
This will return a py2neo.Subgraph of the schema from the beginning of our script. Same as call db.schema.visualization but with a timemachine :)
Release files for NeoMetaTracker 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| NeoMetaTracker-0.0.11.tar.gz | 139.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| NeoMetaTracker-0.0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 150.3 kB
Release files / NeoMetaTracker-0.0.11.tar.gz
| Download URL | NeoMetaTracker-0.0.11.tar.gz |
|---|---|
| Size | 139.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
776c173ff4f3e6e46d91cfafa1898b84da9ada612215ca9ee0abdb01fe4d7a18
|
|
BLAKE2b-256 checksum How to use checksums |
13421d47effef1c436598fe824806afdb1f6e6ca031728993fdf0ef0593ae93e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / NeoMetaTracker-0.0.11-py3-none-any.whl
| Download URL | NeoMetaTracker-0.0.11-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c31d2239e239f6d09633920721d939d005b78d4d3d2d35b9f941da8c2600163d
|
|
BLAKE2b-256 checksum How to use checksums |
8ee37283ffdef6233034ad496862a95b823223e80d46594f196ca30c789ead16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|