Difference between revisions of "Pyjanusgraph"

From BITPlan Wiki
Jump to navigation Jump to search
Line 18: Line 18:
 
<source lang='bash'>
 
<source lang='bash'>
 
pip install -i https://test.pypi.org/simple/ pyjanusgraph==0.0.1a2
 
pip install -i https://test.pypi.org/simple/ pyjanusgraph==0.0.1a2
 +
</source>
 +
= Usage =
 +
First start your janusgraph server e.g. by using the docker command:
 +
<source lang='bash'>
 +
docker run --name jg -it -p 8182:8182 --mount source=/$HOME/graphdata,target=/graphdata,type=bind janusgraph/janusgraph
 +
</source>
 +
=== accessing a remote graph ===
 +
<source lang='python'>
 +
from tp.gremlin import RemoteGremlin
 +
import os
 +
rg = RemoteGremlin()
 +
g=rg.open()
 +
vList = g.V().toList()
 +
print ("found %d vertices" % (len(vList)))
 +
rg.close()
 +
</source>
 +
=== sharing data ===
 +
<source lang='python'>
 +
from tp.gremlin import RemoteGremlin
 +
import os
 +
rg = RemoteGremlin()
 +
rg.setSharepoint(os.path.expanduser("~/graphdata"), "/graphdata/")
 +
g=rg.open()
 +
graphmlFile = "air-routes-small.xml";
 +
shared = rg.share(graphmlPath)
 +
g.io(shared).read().iterate()
 +
vCount = g.V().count().next()
 +
print ("%s has %d vertices" % (shared, vCount))
 +
rg.close()
 
</source>
 
</source>
  

Revision as of 09:26, 13 April 2020

OsProject

OsProject
edit
id  pyjanusgraph
state  
owner  BITPlan
title  Python janusgraph utility library
url  https://github.com/BITPlan/pyjanusgraph
version  0.0.1a1
description  
date  2020/04/12
since  
until  

Motivation

JanusGraph is the first Apache Tinkerpop graph database i could work with Gremlin Python.

pyjanusgraph shall make it easier to work with JanusGraph from Python

Installation

pip install -i https://test.pypi.org/simple/ pyjanusgraph==0.0.1a2

Usage

First start your janusgraph server e.g. by using the docker command:

docker run --name jg -it -p 8182:8182 --mount source=/$HOME/graphdata,target=/graphdata,type=bind janusgraph/janusgraph

accessing a remote graph

from tp.gremlin import RemoteGremlin
import os
rg = RemoteGremlin()
g=rg.open()
vList = g.V().toList()
print ("found %d vertices" % (len(vList)))
rg.close()

sharing data

from tp.gremlin import RemoteGremlin
import os
rg = RemoteGremlin()
rg.setSharepoint(os.path.expanduser("~/graphdata"), "/graphdata/")
g=rg.open()
graphmlFile = "air-routes-small.xml";
shared = rg.share(graphmlPath)
g.io(shared).read().iterate()
vCount = g.V().count().next()
print ("%s has %d vertices" % (shared, vCount))
rg.close()

Links