Skip to main content

Imports object structures generated by MongoDB object relation mappers (like Mongoose) into Neo4j for exploration with SemSpect

Project description

mongo2neo4j

MongoDB Mongoose to Neo4j Importer

License Pylint Ruff Mypy pytest coverage

What is mongo2neo4j?

Imports object relations generated by Object Relation Mappers (ORMs) like Mongoose and stored in MongoDB into the graph database management system Neo4j for exploration with the no-code graphical querying tool SemSpect. Further relations between objects can be specified via options.

What for?

Imagine you just released your latest MEAN-stack app and want to learn how it is used. You could write some MongoDB queries to find out "how many users of the free tier are at all producing some data?", "which feature is used most by subscribers?", ... But maybe you never find time to write those queries or you do not know exact what to look for. A graphical large-data exploration tool like SemSpect comes in handy, which allows you to discover patterns in your data by simple navigation.

As SemSpect is layered on top of the graph database system Neo4j as graph app, your MongoDB data needs first to be established in Neo4j. This can be easily achieved using the mongo2neo4j tool.

How does it work?

The mongodb2neo4j script creates a label (class of nodes) in Neo4j for each collection in the given MongoDB and adds nodes in Neo4j for all documents. Cross-references between MongoDB documents using unique ObjectId identifiers are turned into Neo4j relations, nicely rendered by SemSpect.

Installation

Install Neo4j

The free Neo4j Desktop works well (see Neo4j)

Install SemSpect Plugin

The free SemSpect Graph App for Neo4j works well (see SemSpect)

Install mongo2neo4j

Note: mongo2neo4j requires Python 3.11 or newer.

% pip3 install mongo2neo4j

Run the importer

You can run the mongo2neo4jimporter from the shell by providing at least the name of the MongoDB DB the data should be imported from. If not specified the default neo4j DB is targeted with the default neo4j user. It is likely that you will have to add passwords.

% mongo2neo4j \
  [--mongo_host mongodb://<mongo_user>:<mongo_password>@<mongo_host>] \
  [--neo4j_user=<neo4j_user>] [--neo4j_password=<neo4j_password>] \
  <mongo_db>

Further configuration options are listed on calling

% mongo2neo4j -h

See Script Arguments for the full list of available arguments and the example documenting the workflow of mongo2neo4j using randomly generated sample data.

NOTE: if the APOC plugin is installed in the Neo4j DB, the faster and memory-effective apoc.periodic.iterate method is used to generate nodes and sublabels.

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

mongo2neo4j-1.0.3.tar.gz (57.8 kB view hashes)

Uploaded Source

Built Distribution

mongo2neo4j-1.0.3-py3-none-any.whl (40.8 kB view hashes)

Uploaded Python 3

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