开源图形数据库cayley的python客户端

pyle的Python项目详细描述


https://github.com/ziyasal/pyley/raw/master/pyley.png?raw=true

皮雷

https://travis-ci.org/ziyasal/pyley.svg?branch=masterhttps://coveralls.io/repos/ziyasal/pyley/badge.svg?branch=master&service=github

Python开源图形数据库的客户端cayleyhttps://github.com/google/cayley

Cayley is an open-source graph inspired by the graph database behind Freebase and Google’s Knowledge Graph. Its goal is to be a part of the developer’s toolbox where Linked Data and graph-shaped data (semantic webs, social networks, etc) in general are concerned.

通过PIP安装

您可以使用:

$ pip install pyley

样本

导入通道:

import pyley

# Create cayley client
client = CayleyClient() # this creates client with default parameters `http://localhost:64210/api/v1/query/gizmo`
#or  specify `url` and `version` parameters
client = CayleyClient("http://localhost:64210", "v1")

g = GraphObject()

# Query all vertices in the graph, limit to the first 5 vertices found.
g.Vertex().GetLimit(5)

# Start with only one vertex, the literal name "Humphrey Bogart", and retrieve all of them.
query = g.Vertex("Humphrey Bogart").All();
response = client.Send(query)
# response.result contains JSON data and response.r contains raw response
print response.result

# `g` and `V` are synonyms for `graph` and `Vertex` respectively, as they are quite common.
query = g.V("Humphrey Bogart").All()
response = client.Send(query)

# "Humphrey Bogart" is a name, but not an entity. Let's find the entities with this name in our dataset.
# Follow links that are pointing In to our "Humphrey Bogart" node with the predicate "name".
query = g.V("Humphrey Bogart").In("name").All()
response = client.Send(query)

# Notice that "name" is a generic predicate in our dataset.
# Starting with a movie gives a similar effect.
query = g.V("Casablanca").In("name").All()
response = client.Send(query)

# Relatedly, we can ask the reverse; all ids with the name "Casablanca"
query = g.V().Has("name", "Casablanca").All()
response = client.Send(query)

# Let's get the list of actors in the film
query = g.V().Has("name", "Casablanca") \
              .Out("/film/film/starring") \
              .Out("/film/performance/actor") \
              .Out("name") \
              .All()

response = client.Send(query)

# But this is starting to get long. Let's use a morphism -- a pre-defined path stored in a variable -- as our linkage
film_to_actor = g.Morphism().Out("/film/film/starring").Out("/film/performance/actor")
query = g.V() \
        .Has("name", "Casablanca") \
        .Follow(film_to_actor) \
        .Out("name") \
        .All()
response = client.Send(query)

# Add data programatically to the JSON result list. Can be any JSON type.
query = g.Emit({'name': "John Doe", 'age': 41, 'isActor': True})
response = client.Send(query)

虫子

如果遇到错误、性能问题或故障,请添加一个Issues,其中包含有关如何重现问题的步骤。

待办事项

  • 改进gizmo实现(目前实现的基本步骤)
  • 添加更多测试
  • 添加更多文档

正在使用的开源项目

许可证

@ziλasal&;@abdullahselek

代码和文档根据mit许可证提供(请参见LICENSE)。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在JavaSpring引导应用程序中合并两个对象?   java序列化与防止按钮、链接等被点击两次有关吗?   java CORBA序列:我可以用方法定义对象序列吗?   java没有SonarQube的Spring批处理项目的代码覆盖   java如何在eclipse中删除上述方法和属性的搜索引用链接   spring boot如何在java注释中使用泛型T类型?   java导入外部(未编译)groovy类,并将它们保留在jar之外   如何在int[]Java中找到所有值的总和?   Java在ArrayList中删除重复项的问题   Java更改菜单栏、项目背景和文本颜色   网络设置网络。使用Elasticsearch JAVA API将主机发布到客户端节点   Python到Java加密/解密,确保密码匹配?   java Faing在Ubuntu12.04上构建eucalyptus的困难   java使用org。阿帕奇。平民fileupload在mysql数据库中上传图像,但调用servlet会得到一个空白的白页