Difference between revisions of "Gremlin python"
Jump to navigation
Jump to search
Line 85: | Line 85: | ||
$gsd/bin/gremlin-server.sh $conf | $gsd/bin/gremlin-server.sh $conf | ||
</source> | </source> | ||
+ | <pre> | ||
+ | ./run -c | ||
+ | starting gremlin-console ... | ||
+ | |||
+ | \,,,/ | ||
+ | (o o) | ||
+ | -----oOOo-(3)-oOOo----- | ||
+ | plugin activated: tinkerpop.server | ||
+ | plugin activated: tinkerpop.utilities | ||
+ | plugin activated: tinkerpop.tinkergraph | ||
+ | gremlin> g=traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g')) | ||
+ | No signature of method: groovysh_evaluate.DriverRemoteConnection() is applicable for argument types: (String, String) values: [ws://localhost:8182/gremlin, g] | ||
+ | Type ':help' or ':h' for help. | ||
+ | </pre> |
Revision as of 13:05, 17 September 2019
This mini-tutorial is inspired by this stackoverflow question
The goal is to get access to an apache tinkerpop/gremlin graph database via Python.
Prerequisites
- Java
- Python
- Gremlin-Server
- Gremlin-Console (for debugging)
Installing Java
sudo apt-get install openjdk-8-jre
java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
Installing Python and Pip
sudo apt install python2.7
python --version
Python 2.7.15+
sudo apt install python-pip
pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Installing Gremlin Server and Console
Installlation automation
#!/bin/bash
# WF 2019-09-17
# test gremlin-python
# see https://stackoverflow.com/questions/57936915/how-do-i-get-gremlin-python-with-gremlin-server-3-4-3-to-work
# check that the given program is installed
checkinstalled() {
local l_prg="$1"
local l_version="$2"
local l_package="$3"
which $l_prg
if [ $? -ne 0 ]
then
echo "$l_prg is not available - shall i install it from $l_package y/n?"
read x
case $x in
y) sudo apt-get install $l_package;;
*) echo "aborting ..."
exit 1;;
esac
fi
$l_prg $l_version
}
echo "checking prerequisites ..."
checkinstalled java "-version" "openjdk-8-jre"
checkinstalled python "--version" "python2.7"
checkinstalled pip "--version" "python-pip"
version=3.4.3
mirror=http://mirror.dkd.de/apache/tinkerpop/$version
gsd=apache-tinkerpop-gremlin-server-${version}
gcd=apache-tinkerpop-gremlin-console-${version}
for d in $gsd $gcd
do
if [ ! -d $d ]
then
zip=$d-bin.zip
if [ ! -f $zip ]
then
echo "downloading $zip"
curl -s $mirror/$zip -o $zip
else
echo "$zip already downloaded"
fi
echo "unzipping $zip"
unzip $zip
else
echo "$d already unzipped"
fi
done
echo "starting gremlin-server ..."
conf=$(realpath $gsd/conf/gremlin-server-modern-py.yaml)
$gsd/bin/gremlin-server.sh $conf
./run -c starting gremlin-console ... \,,,/ (o o) -----oOOo-(3)-oOOo----- plugin activated: tinkerpop.server plugin activated: tinkerpop.utilities plugin activated: tinkerpop.tinkergraph gremlin> g=traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g')) No signature of method: groovysh_evaluate.DriverRemoteConnection() is applicable for argument types: (String, String) values: [ws://localhost:8182/gremlin, g] Type ':help' or ':h' for help.