Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rochacbruno-archive/OrientEngine
A Python Object-Graph-Document-Mapper for working with OrientDB
https://github.com/rochacbruno-archive/OrientEngine
Last synced: 10 days ago
JSON representation
A Python Object-Graph-Document-Mapper for working with OrientDB
- Host: GitHub
- URL: https://github.com/rochacbruno-archive/OrientEngine
- Owner: rochacbruno-archive
- License: mit
- Created: 2014-07-10T01:43:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-15T16:45:11.000Z (almost 10 years ago)
- Last Synced: 2024-08-01T22:56:26.592Z (3 months ago)
- Language: Python
- Size: 184 KB
- Stars: 12
- Watchers: 8
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
OrientEngine
============A Python Object-Graph-Document-Mapper for working with OrientDB
> This project is a META-Project using the RDD (Readme Driven Development) process.
- Inspired by [MongoEngine](http://github.com/mongoengine)
- Based in [PyOrient](https://github.com/rochacbruno/pyorient)The idea
========There is already awesome projects to work with Python and OrientDB, BulbFlow + Rexter is the most used tools, but they use HTTP/REST interface which is great but sometimes is slow and unstable (depending on your stack).
Using PyOrient Driver is really faster!
OrientEngine will provide **Vertex, Edge, Class and Cluster** classes to be extended in order to create Graph and Document database representation.
```python
#### edges.py
from orientengine import Edge, InEdgeInterface, OutEdgeInterface IntPropertyclass Eat(Edge):
amount = IntProperty()
class Eater(OutEdgeInterface):
action = 'eat'
action_plural = 'eats' # there is also get_plural_action and get_singular_action if it needs to be dynamic
edge = Eat
validators = []
def link(self,):
# optionally you can override the out link method
class Eatable(InEdgeInterface):
related_names = ('eaters', 'who_eats') # multiple terms can be used
edge = Eat
validators = []
def link(self,):
# optionally you can override the in link method
#### vertices.pyfrom orientengine import Vertex, StringProperty
from .edges import Eatable, Eaterclass Animal(Vertex, Eater): # Can eat Out
specie = StringProperty()
name = StringProperty()class Food(Vertex, Eatable): # Can be eated In
color = StringProperty()
name = StringProperty()#### SHELL
>>> import orientengine
>>> orientengine.connect(uri="localhost:2424", db="animals", user="admin", password="12345")
>>> from vertices import Animal, Food
>>> rat = Animal(specie='rodent', name='rat')
>>> man = Animal(specie='human', name='man')
>>> pea = Food(color='green', name='pea')# define some links (edges)
# on each vertex
>>> rat.eat(pea)
>>> man.eat(pea, amount=30)# or extending another vertex "in" connection
>>> pea.eaters.extend(rat, man)
# or a vertex can eat any foods at the same time
>>> man.eats([pea, corn, rice, tofu])# Who eats peas?
# Starting by the pea Vertex
>>> pea.eaters
[, , ...]# or starting by Animal class
>>> Animal.objects(eats=pea) or Animal.objects(who_eats=pea)
[, , ...]```