In this how-to, I’m going to show you how you can access your OrientDB Graph database in your Python projects.
Introduction
What is OrientDB?
— fromĀ http://www.orientdb.org/
OrientDB is a mix of 2 database technology: Document-oriented and Object-oriented databases. Also, one of the advantages of OrientDB compared to other NoSQL databases is its SQL-like query language. This means that there will be less-hassle learning to query the data for the people coming from the RDBMS world. There are also other features like:
- Graph database support
- Document database support
- Object database support
- Dictionary indexes support
- A SQL-like query language
- Transaction support
- Hooks (a sort of trigger, but at the system level rather than class level)
- Custom SQL function (to write your own functions in Java to expand the SQL parser)
- Stored procedures
- Plugin support to add features to the server’s core
- REST interface
- Java API library
- Clustering
Here is a slide that describes what OrientDB is.
Why OrientDB?
In my opinion, the top 3 players in the Graph Database world are Neo4j, OrientDB and Titan. I have listed the 3 graph databases and the reasons why I chose OrientDB.
Neo4j
Free for a single-node setup. High-availability and Clustering available in the Enterprise edition. I’ve been reading a lot of good things about Neo4j but I don’t want to be limited with a single node. Specially for open-sourced projects where it can’t afford to avail the Enterprise edition.
Titan
One thing that pulled me out in using Titan is I have to setup the separate database backend. One feature I want in a database is that I can use it right away during development. Anyway, it can use Cassandra, HBase and Oracle BerkleyDB for its database backend. But it doesn’t mean that Titan is inferior to the two other Graph database. Actually, I think Titan can scale a lot compared to the other 2. Cassandra and HBase are used and proven in a lot of production applications and can handle multi-billions of data.
OrientDB
What I like with OrientDB is that you can run it using the compiled version available for download in their website. Download, extract and run – that’s it. You can access your database through its built-in Web UI. There’s also the Graph Edition of OrientDB which includes some parts of the TinkerPop stack like:
- Blueprints
- Gremlin
- Pipes
Oracle Java installation on Ubuntu
This portion will show you how you can install Oracle Java VM. Thanks to Webupd8 Team for providing the deb package.
Before proceeding, we should first switch to root.
sudo -i
Install webupd8’s Ubuntu repository. This is where we’re gonna pull the package that downloads and installs
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.d/oracle_java.list echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.d/oracle_java.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
Update, install and activate.
apt-get update apt-get install oracle-java7-installer apt-get install oracle-java7-set-default
OrientDB Graph Edition Installation
We are going to use the GraphEd version of OrientDB.
wget https://s3.amazonaws.com/orientdb/releases/orientdb-graphed-1.5.1.zip apt-get install -y unzip unzip orientdb-graphed-1.5.1.zip
Make the scripts on bin executable and start the server.
cd /opt/orientdb-graphed-1.5.1/bin chmod -R +x bin ./server.sh
Now, point your browser to http://<server_ip>:2480/studio to access the OrientDB Studio. The graph edition includes a sample graph database that we can use.
The name of the sample database is “tinkerpop” and the default username and password is “admin”.
On our next part, I will show you how to install rexster. Rexster will be used to interface the OrientDB graph database to python using the BulbFlow module. For the mean time, you can check the overview of BulbFlow and Rexster
root@node1:/opt/orientdb-graphed-1.5.1/bin# ./server.sh . .` ` , `:. `,` ,:` .,. :,, .,, ,,, . .,.::::: ```` ,` .::,,,,::.,,,,,,`;; .: `,. ::,,,,,,,:.,,.` ` .: ,,:,:,,,,,,,,::. ` ` `` .: ,,:.,,,,,,,,,: `::, ,, ::,::` : :,::` :::: ,:,,,,,,,,,,::,: ,, :. : :: : .: :,,,,,,,,,,:,:: ,, : : : : .: ` :,,,,,,,,,,:,::, ,, .:::::::: : : .: `,...,,:,,,,,,,,,: .:,. ,, ,, : : .: .,,,,::,,,,,,,: `: , ,, : ` : : .: ...,::,,,,::.. `: .,, :, : : : .: ,::::,,,. `: ,, ::::: : : .: ,,:` `,,. ,,, .,` ,,. `, GRAPH-DB Server `` `. `` ` 2013-10-22 03:59:21:320 INFO Profiler is recording metrics with configuration: 0,0,0 [OJVMProfiler] 2013-10-22 03:59:21:327 INFO Loading configuration from: /opt/orientdb-graphed-1.5.1/config/orientdb-server-config.xml... [OServerConfigurationLoaderXml] 2013-10-22 03:59:21:475 INFO OrientDB Server v1.5.1 (build @BUILD@) is starting up... [OServer] 2013-10-22 03:59:21:500 INFO Port 0.0.0.0:2424 busy, trying the next available... [OServerNetworkListener] 2013-10-22 03:59:21:500 INFO Listening binary connections on 0.0.0.0:2425 (protocol v.17) [OServerNetworkListener] 2013-10-22 03:59:21:501 INFO Port 0.0.0.0:2480 busy, trying the next available... [OServerNetworkListener] 2013-10-22 03:59:21:501 INFO Listening http connections on 0.0.0.0:2481 (protocol v.10) [OServerNetworkListener] 2013-10-22 03:59:21:518 INFO Installing GREMLIN language v.2.5.0-SNAPSHOT - graph.pool.max=50 [OGraphServerHandler] 2013-10-22 03:59:21:521 INFO OrientDB Server v1.5.1 is active. [OServer]