Add Neo4j Cypher export (--neo4j)#2774
Merged
Merged
Conversation
Serialize the maigret graph (the same one --graph builds) into an idempotent Cypher script importable into Neo4j. Reuses MaigretGraph via an extracted _build_maigret_graph() helper, leaving save_graph_report behavior unchanged; no new runtime dependency. Adds the --neo4j flag, the neo4j_report setting, docs, and a unit test. Closes soxoj#2630
Contributor
Author
Owner
|
@thunderstornX amazing job, thanks a lot for an amazing contribution! |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds a
--neo4jexport that serializes the maigret graph (the same one--graphbuilds) into a Cypher script importable into Neo4j, per #2630 and your go-ahead there.Closes #2630
What it does
maigret <username> --neo4jwrites a*_neo4j.cypherfile. It reuses the existingMaigretGraph(the structure behind--graph), so it captures the same username / account / site / data nodes and relationships, and serializes them as idempotent Cypher:MERGEd on a uniquename(re-imports do not create duplicates),[:LINKED_TO]relationships,CREATE CONSTRAINT ... IF NOT EXISTSon the node name.No new runtime dependency (
networkxis already used). Import withcypher-shell -u neo4j -p <pw> < <file>.cypher, or paste into the Neo4j Browser.Refactor
I extracted the graph-building out of
save_graph_reportinto a shared_build_maigret_graph()helper so both--graphand--neo4juse it;save_graph_reportbehavior is unchanged.Testing
tests/test_report.py::test_generate_neo4j_report(covers the Cypher structure plus escaping of quotes and newlines) and updatedtests/test_cli.py's arg baseline for the new flag. No regressions;--graphstill works.--neo4jto the README usage block anddocs/source/command-line-options.rst.Note: the
CREATE CONSTRAINT ... IF NOT EXISTS FOR ... REQUIREline uses Neo4j 4.4+ syntax; theMERGEstatements keep the import idempotent on any version.