Skip to main content

Track and visualize changes in a Neo4j database schema

Project description

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:

"docs/01_test_base_graph.png"

and the schema will look like this:

"docs/03_schema.png"

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

"docs/docs/02_graph_extended.png"

The schema still looks the same. We wont be able to recognize changes without any help:

call db.schema.visualization

"docs/03_schema.png"

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:

"docs/04_schema_changes.png"

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 :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NeoMetaTracker-0.0.6.tar.gz (138.6 kB view details)

Uploaded Source

Built Distribution

NeoMetaTracker-0.0.6-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file NeoMetaTracker-0.0.6.tar.gz.

File metadata

  • Download URL: NeoMetaTracker-0.0.6.tar.gz
  • Upload date:
  • Size: 138.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for NeoMetaTracker-0.0.6.tar.gz
Algorithm Hash digest
SHA256 c5e5435a779f4e150c2b872a4fd0d3e32e5912b376f661b5b16d6a80376fea0f
MD5 2b49ecb29f843d9032bd943a4c15b339
BLAKE2b-256 9111cde5474fb602fdd06e7fed9a6ae115a70aab7ea4d5b963a960bdf4a610c9

See more details on using hashes here.

File details

Details for the file NeoMetaTracker-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for NeoMetaTracker-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b6e9cb9cf7aad5fad8b788118f5de18e8cdec78c059f87c4d4ce550baedd6c6e
MD5 c833fd1c7c15548295cbef9d9b574c21
BLAKE2b-256 2b523fd5d5c155ca8be520d1946e7136466ade0ae75c22a1e49153db628d6f65

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page