Neo4j推出基于Python的嵌入式图数据存储


Neo4j很早就在说,会推出一个嵌入Python中的图数据库模块,让Python可以通过图数据库的API操作本地文件以存储图结构的数据(类似于很多支持SQLite的类库)。而今天Neo4j终于在官方博客上兑现了其承诺,并为自己的多次跳票表示抱歉。

First of all, we’re really sorry. We have been saying that Python support for the embedded database is coming in “a few weeks” or “next month” for over half a year now, and so far, you have waited patiently, and you have waited in vain.

先看一下使用方法

#import相应的包
from neo4j import GraphDatabase
#创建基于本地文件的图数据库
db = GraphDatabase('/my/db/location')
#存储数据
with db.transaction:
    oscar = db.node(name=’Oscar Wilde’)
    jacob = db.node(name=’Jacob’)

    # Create a relationship
    oscar.impressed_by_blogging_skills_of(jacob)
#关闭数据库
db.shutdown()

目前最新版本在CPython2.7.2  Windows和Linux下都经过测试,在Python2.6版本下也可以正常工作。你需要安装JPype以在Python和Java间建立桥梁。更多详细介绍及使用说明见neo4j的官方文档:docs.neo4j.org

相关内容