Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wgwz/flask-py2neo
integration of py2neo with flask
https://github.com/wgwz/flask-py2neo
flask neo4j py2neo
Last synced: about 2 months ago
JSON representation
integration of py2neo with flask
- Host: GitHub
- URL: https://github.com/wgwz/flask-py2neo
- Owner: wgwz
- License: mit
- Created: 2017-05-18T14:41:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-25T03:57:33.000Z (about 3 years ago)
- Last Synced: 2023-02-28T16:52:28.059Z (almost 2 years ago)
- Topics: flask, neo4j, py2neo
- Language: Python
- Size: 8.79 KB
- Stars: 12
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask-Py2Neo
Flask-Py2Neo is mostly a connection utility. The aim is to get you up and running as quickly as possible. It also aims to use best-practices in terms of how the connection is made between `py2neo` and your Neo4j instance.
## Quickstart
Here is a quickstart guide. It shows how to initialize and make use of the extension.
To initialize in an application module:
```python
from flask import Flask, jsonify
from flask_py2neo import Py2Neoapp = Flask(__name__)
db = Py2Neo(app)
```Or this pattern:
```python
from flask import Flask, jsonify
from flask_py2neo import Py2Neoapp = Flask(__name__)
db = Py2Neo()
db.init_app(app)
```Then define some view functions:
```python
@app.route('/create/')
def create(name):
db.graph.run("CREATE (n:User {name: '%s'})" % name) # noqa
return jsonify('user %s created' % name)@app.route('/list/')
def list():
return jsonify(db.graph.run("MATCH (n:User) RETURN n").data())
```## Object-Graph Mapper
```python
from py2neo.ogm import GraphObject, Propertyclass Post(GraphObject):
title = Property()
post = Post()
post.title = 'my first post'db.graph.push(post)
```## References
- py2neo v3 Handbook: http://py2neo.org/v3/
- py2neo v4 Handbook: http://py2neo.org/v4/
- py2neo v3 OGM: http://py2neo.org/v3/ogm.html
- py2neo v4 OGM: http://py2neo.org/v4/ogm.html
- py2neo: https://github.com/technige/py2neo
- Flask: https://github.com/pallets/flask## Useful tidbits
- Cypher Ref Card: https://neo4j.com/docs/cypher-refcard/current/