我想知道有一个ORM与图数据库(fe Neo4j)的解决方案(或需要).我跟踪关系(A与B相关,它与A通过C等相关,从而构建一个大图)实体(包括那些实体的附加属性)并需要将它们存储在DB中,我认为图形数据库完全适合这项任务.
现在,对于类似sql的数据库,我使用sqlalchemyśORM来存储我的对象,特别是因为我可以从数据库中检索对象并以pythonic样式使用它们(使用它们的方法等).
Neo4j或其他Graph-DB是否有任何对象映射解决方案,以便我可以在Graph-DB中存储和检索python对象并轻松使用它们?
或者你会编写一些函数或适配器,如python sqlite文档(http://docs.python.org/library/sqlite3.html#letting-your-object-adapt-itself)来检索和存储对象?
我目前正在为neo4j使用嵌入式python绑定.我目前没有任何问题,因为我的图表非常小(稀疏和高达100个节点).我正在开发的算法在图上涉及相当多的遍历,更具体地说是图上的DFS以及不同的子图.在未来,我打算在大图上运行算法(据说是稀疏的,有数百万个节点).
有与python /的Neo4j绑定的性能阅读不同的线程在这里,在这里,我不知道我是否应该已经切换到一些REST API客户端的Python(如bulbflow,py2neo,neo4jrestclient),直到我太远改变所有代码.
不幸的是,我没有找到任何综合的信息来源来比较不同的方法.
任何人都可以进一步了解这个问题吗?选择其中一个选项时,我应该考虑哪些标准?
我想Neo4j
用python脚本将一些数据放到数据库中.我认为bulbflow可以很容易地做到这一点.
我在他们的主页和文档中有这个小脚本.
#!/usr/bin/python
from bulbs.neo4jserver import Graph
g = Graph()
james = g.vertices.create(name="James")
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我收到此错误:
Traceback (most recent call last):
File "./bulb.py", line 4, in <module>
james = g.vertices.create(name="James")
File "/usr/lib/python2.7/site-packages/bulbs/element.py", line 565, in create
resp = self.client.create_vertex(data, keys=_keys)
File "/usr/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 424, in create_vertex
return self.create_indexed_vertex(data, index_name, keys=keys)
File "/usr/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 1054, in create_indexed_vertex
return self.gremlin(script,params)
File "/usr/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 384, in gremlin
return self.request.post(path, params)
File "/usr/lib/python2.7/site-packages/bulbs/rest.py", line 131, in post
return self.request(POST, path, params)
File …
Run Code Online (Sandbox Code Playgroud) 我现在正在尝试学习如何使用Python中的Bulbflow连接到Neo4j服务器并在其上运行Cypher查询.我不明白的是连接到neo4j服务器的两种可能性之间的区别:
1)图表
from bulbs.neo4jserver import Graph
g = Graph()
Run Code Online (Sandbox Code Playgroud)
from bulbs.neo4jserver import Neo4jClient
client = Neo4jClient()
Run Code Online (Sandbox Code Playgroud)
有谁能请解释这里的概念差异?哪种方式更好的选择我是否想要执行(相当多)Cypher查询服务器并最终并行执行?
PS:我没有足够的声誉为这个问题创建一个标签"bulbflow":)
所以,我在mac-osx上使用python3.2和灯泡,使用rexster和orientdb.细节:
orientdb - 从他们的页面下载标准
〜/工作区/ orientdb社区-1.7-RC1
运行服务器, ./bin/server.sh
database - orientdb database~/databases/orientdb/dev-db-01
rexster - 来自github git clone的标准结账git://github.com/tinkerpop/rexster.wiki.git~/ workspace /
配置/ rexster.xml:
...
<graph>
<graph-enabled>true</graph-enabled>
<graph-name>dev-db-01</graph-name>
<graph-type>orientgraph</graph-type>
<graph-location>local:*<path to...>*/databases/orientdb/dev-db-01</graph-location>
<properties>
<username>admin</username>
<password>admin</password>
</properties>
<extensions>
<allows>
<allow>tp:gremlin</allow>
</allows>
</extensions>
</graph>
...
Run Code Online (Sandbox Code Playgroud)
Python代码:
from bulbs.rexster import Graph
from bulbs.config import Config
config = Config("http://localhost:8182/dev-db-01/", username="admin", password="admin")
g = Graph(config)
Run Code Online (Sandbox Code Playgroud)
问题:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/bulbs/rexster/graph.py", li ne 56, in __init__
super(Graph, self).__init__(config) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/bulbs/base/graph.py", line …
Run Code Online (Sandbox Code Playgroud) 我正在使用Titan Rexster(titan-server-0.4.4.zip)和Elasticsearch后端在Ubuntu 12.4服务器上运行推荐系统.为了连接到Rexster Server,我使用Bulbflow库进行python.
Beta似乎运行良好3周,但随着负载"增加"(只有几个用户~10),Rexster服务器停止响应.我不知道我的rexster配置是错误的还是我没有正确使用Bulbflow库.
这是我的rexster-cassandra-es.xml:
<?xml version="1.0" encoding="UTF-8"?>
<rexster>
<http>
<server-port>8182</server-port>
<server-host>0.0.0.0</server-host>
<base-uri>http://MY_IP</base-uri>
<web-root>public</web-root>
<character-set>UTF-8</character-set>
<enable-jmx>false</enable-jmx>
<enable-doghouse>true</enable-doghouse>
<max-post-size>2097152</max-post-size>
<max-header-size>8192</max-header-size>
<upload-timeout-millis>30000</upload-timeout-millis>
<thread-pool>
<worker>
<core-size>20</core-size>
<max-size>40</max-size>
</worker>
<kernal>
<core-size>10</core-size>
<max-size>20</max-size>
</kernal>
</thread-pool>
<io-strategy>leader-follower</io-strategy>
</http>
<rexpro>
<server-port>8184</server-port>
<server-host>0.0.0.0</server-host>
<session-max-idle>1790000</session-max-idle>
<session-check-interval>3000000</session-check-interval>
<connection-max-idle>180000</connection-max-idle>
<connection-check-interval>3000000</connection-check-interval>
<enable-jmx>false</enable-jmx>
<thread-pool>
<worker>
<core-size>8</core-size>
<max-size>8</max-size>
</worker>
<kernal>
<core-size>4</core-size>
<max-size>4</max-size>
</kernal>
</thread-pool>
<io-strategy>leader-follower</io-strategy>
</rexpro>
<shutdown-port>8183</shutdown-port>
<shutdown-host>127.0.0.1</shutdown-host>
<script-engines>
<script-engine>
<name>gremlin-groovy</name>
<reset-threshold>-1</reset-threshold>
<imports>com.tinkerpop.gremlin.*,com.tinkerpop.gremlin.java.*,com.tinkerpop.gremlin.pipes.filter.*,com.tinkerpop.gremlin.pipes.sideeffect.*,com.tinkerpop.gremlin.pipes.transform.*,com.tinkerpop.blueprints.*,com.tinkerpop.blueprints.impls.*,com.tinkerpop.blueprints.impls.tg.*,com.tinkerpop.blueprints.impls.neo4j.*,com.tinkerpop.blueprints.impls.neo4j.batch.*,com.tinkerpop.blueprints.impls.orient.*,com.tinkerpop.blueprints.impls.orient.batch.*,com.tinkerpop.blueprints.impls.dex.*,com.tinkerpop.blueprints.impls.rexster.*,com.tinkerpop.blueprints.impls.sail.*,com.tinkerpop.blueprints.impls.sail.impls.*,com.tinkerpop.blueprints.util.*,com.tinkerpop.blueprints.util.io.*,com.tinkerpop.blueprints.util.io.gml.*,com.tinkerpop.blueprints.util.io.graphml.*,com.tinkerpop.blueprints.util.io.graphson.*,com.tinkerpop.blueprints.util.wrappers.*,com.tinkerpop.blueprints.util.wrappers.batch.*,com.tinkerpop.blueprints.util.wrappers.batch.cache.*,com.tinkerpop.blueprints.util.wrappers.event.*,com.tinkerpop.blueprints.util.wrappers.event.listener.*,com.tinkerpop.blueprints.util.wrappers.id.*,com.tinkerpop.blueprints.util.wrappers.partition.*,com.tinkerpop.blueprints.util.wrappers.readonly.*,com.tinkerpop.blueprints.oupls.sail.*,com.tinkerpop.blueprints.oupls.sail.pg.*,com.tinkerpop.blueprints.oupls.jung.*,com.tinkerpop.pipes.*,com.tinkerpop.pipes.branch.*,com.tinkerpop.pipes.filter.*,com.tinkerpop.pipes.sideeffect.*,com.tinkerpop.pipes.transform.*,com.tinkerpop.pipes.util.*,com.tinkerpop.pipes.util.iterators.*,com.tinkerpop.pipes.util.structures.*,org.apache.commons.configuration.*,com.thinkaurelius.titan.core.*,com.thinkaurelius.titan.core.attribute.*,com.thinkaurelius.titan.core.util.*,com.thinkaurelius.titan.example.*,org.apache.commons.configuration.*,com.tinkerpop.gremlin.Tokens.T,com.tinkerpop.gremlin.groovy.*</imports>
<static-imports>com.tinkerpop.blueprints.Direction.*,com.tinkerpop.blueprints.TransactionalGraph$Conclusion.*,com.tinkerpop.blueprints.Compare.*,com.thinkaurelius.titan.core.attribute.Geo.*,com.thinkaurelius.titan.core.attribute.Text.*,com.thinkaurelius.titan.core.TypeMaker$UniquenessConsistency.*,com.tinkerpop.blueprints.Query$Compare.*</static-imports>
</script-engine>
</script-engines>
<security>
<authentication>
<type>none</type>
<configuration>
<users>
<user>
<username>rexster</username>
<password>rexster</password>
</user>
</users>
</configuration>
</authentication>
</security>
<metrics>
<reporter> …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个基于neo4j的数据密集型Python应用程序,出于性能原因,我需要在每次事务中创建/恢复多个节点和关系.session.commit()
在灯泡中是否有相当于SQLAlchemy的声明?
编辑:
对于那些感兴趣的人来说,开发了一个可以原生实现该功能的灯泡接口,其功能与SQLAlchemy非常相似:https: //github.com/chefjerome/graphalchemy
我正在构建一个使用BulbFlow的应用程序.BulbFlow ORM类似于Django ORM.作为一个实际的数据库后端,我使用的是带有Rexster 2.2.0的OrientDB 1.3.0.
我想知道是否有人对使用这两种产品有任何见解.BulbFlow允许基于Python的数据模型定义.但是OrientDB有自己的模式定义系统,包括类和约束.有没有办法一起使用它们?或者是Rexster/BulbFlow已经使用了OrientDB的约束系统?
提前感谢您的见解.
我正在使用最新的社区Neo4j(2.2.0-M03)来存储我的图表.我有兴趣从Python访问它.根据官方Neo4j 文档,有几种选择.
根据我的理解,通过检查文档,玩一下,并查看这篇文章,py2neo是唯一一个支持Neo4j 2(和标签).但是,如果我想在Neo4j上编写和运行特定的算法,我应该使用Gremlin,通过灯泡,但是它似乎不支持Neo4j 2.
现在,我想使用一些目前不在Neo4j中的自定义算法,比如Spreading Activation.是用Java编写Neo4j直接编写算法,使用cypher命令通过py2neo从Python运行它们是唯一的选择吗?我错过了什么吗?
干杯
PS.我想发布我引用的所有软件的链接,但不幸的是我需要至少10个声望才能发布超过2个链接...
我正在使用这个api ..其函数调用如下:
g.vertices.index.lookup(identifier="value")
Run Code Online (Sandbox Code Playgroud)
现在请注意,idenitifier是一个我尚未定义但由api解析的变量,value是一个字符串.
类似的事情发生在pymongo api:http://api.mongodb.org/python/current/tutorial.html
db = client.test_database
Run Code Online (Sandbox Code Playgroud)
等于
db = client["test_database"]
Run Code Online (Sandbox Code Playgroud)
test_database在第一种情况下,即使用户没有定义该变量..但mongo可以理解,在我的数据存储区中,我是否有一个名为test_database的数据库.
现在,我遇到的问题是:我的数据存储区中有一个冒号..
这就是说:
g.vertices.index.lookup(bad:identifier="value")
Run Code Online (Sandbox Code Playgroud)
请参阅查询中的冒号..
而这个api没有那个mongo类型的字典实现..
我知道,我应该解决这个问题,为什么我会得到这个结肠..但这就是我现在所困扰的......
问题是因为结肠,我得到了
g.vertices.index.lookup(bad:identifier="value")
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题