Build Graphs On MongoDB Easily
Project description
MongoGraph - build Graph DataBase on top of MongoDB
First of its kind among Python Packages that can be used as a stable client for Graph operations on MongoDB
Setup:
pip install mongograph
Usage:
from mongograph import MongoGraph
MONGO_URL="mongodb+srv://user:password@clusterx.xxxxxxx.mongodb.net/?retryWrites=true&w=majority"
graph_client = MongoGraph(connection_string=URL)
ack = graph_client.is_connected()
print("connected: ",ack)
1. Creating, Updating & Deleting Nodes:
#Create a Node
node_properties = {"name":"myName"}
node_id1 = graph_client.add_node(label="user",properties=node_properties)
print(node_id1)
#Update a Node
import datetime
node_properties = {"name":"myNewName", "todayDate":datetime.datetime.now() }
update_ACK = graph_client.update_node(properties={"name":"no name"}, label="user", node_id=node_id1)
print("updated: ",update_ACK)
#Delete a Node
delete_ACK = graph_client.delete_node(node_id=node_id1, label="user")
print("deleted: ",delete_ACK)
2. Creating, Updating & Deleting Edges:
#Create an Edge
node_id2 = graph_client.add_node(label="user",properties={"name":"yourName"})
edge_id = graph_client.add_edge(label="friends",
from_node_label="user",
to_node_label="user",
from_node_id=node_id2,
to_node_id=node_id1,
properties={"creation":datetime.datetime.now()})
print(edge_id)
#Update an Edge
update_ACK = graph_client.update_edge(label="friends",
edge_id=edge_id ,
properties={"property1":datetime.datetime.now()})
print("updated: ",update_ACK)
#Delete an Edge
delete_ACK = graph_client.delete_edge(edge_id=edge_id, label="friends")
print("deleted: ",delete_ACK)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mongograph-0.0.4.tar.gz
(10.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongograph-0.0.4.tar.gz.
File metadata
- Download URL: mongograph-0.0.4.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eeb4a17f12f9c82afc2d5bc8719fcffd426654ae7f5ee61ac606ca0406264d8
|
|
| MD5 |
b5d076e0589dbd79b681efbdb3e62354
|
|
| BLAKE2b-256 |
afa644f7acdc5707de6b0cf64629761c9901c4bac63b0abdb0be55d7f810bb65
|
File details
Details for the file mongograph-0.0.4-py3-none-any.whl.
File metadata
- Download URL: mongograph-0.0.4-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c7bee2c635660dc0b8a5a54663c51a122ed15994f04de23186067b9e6329fc2
|
|
| MD5 |
ee9e1fec5e63170a7cc6b3c155e7750c
|
|
| BLAKE2b-256 |
acc8daade628db1a5ef5497a57147780118b570c2994a15959d78ab8e4834a55
|