Extension Flask for integration with neo4j graph database
Project description
Flask2Neo4J
Extension Flask for integration with neo4j graph database
Installation
Using pip:
$ pip install flask2neo4j
Usage
Basic Step to usage this extension:
- Create Flask app instance:
import bcrypt
from py2neo import ogm
from flask import Flask, request
from flask2neo4j import Flask2Neo4J
app = Flask(__name__)
- Add NEO4J Config and Initialization Flask2Neo4j Extensions:
app.config["NEO4J_USERNAME"] = "neo4j"
app.config["NEO4J_PASSWORD"] = "neo4j"
app.config["NEO4J_URI"] = "bolt://localhost:7687"
flask2neo = Flask2Neo4J()
flask2neo.init_app(app)
- Create Model using Graph Object if using GraphObject
class Users(ogm.GraphObject):
__primarykey__ = "id"
id = ogm.Property()
username = ogm.Property("username")
password = ogm.Property("password")
def create_password(self, password):
self.password = str(bcrypt.encrypt(password))
@property
def is_exist(self):
return flask2neo.graph.exists(self)
def save(self):
if self.is_exist:
flask2neo.graph.merge(self)
flask2neo.graph.push(self)
else:
flask2neo.graph.create(self)
- Define function register as flask request method
POST
@app.route("/register", methods=["POST"])
def register():
form = request.form
user = Users()
user.username = form['username']
user.create_password(form['password'])
user.save()
return "User Created"
- Run flask app
if __name__ == '__main__':
app.run(port=8500, debug=True)
Open your browser and type into url : http://localhost:8500
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask2Neo4J-0.1a1.tar.gz
(2.4 kB
view details)
Built Distribution
File details
Details for the file Flask2Neo4J-0.1a1.tar.gz
.
File metadata
- Download URL: Flask2Neo4J-0.1a1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0f5787a2c29adf3fc8d2564bb9c6548cf8c93d5855d4b1bcf4ae3b64c20a89 |
|
MD5 | 26fd0177833190191ab7a3f31b4228b6 |
|
BLAKE2b-256 | c74c884fb8859b2aa23060182cdec08b269ecf61941cb034cf0efdc35645ea7e |
File details
Details for the file Flask2Neo4J-0.1a1-py3-none-any.whl
.
File metadata
- Download URL: Flask2Neo4J-0.1a1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1673bcad871003b8c4d538bbfbcc8a2f7ed4351283f2f23d84a483830a91a27f |
|
MD5 | aab6ea675f7d7b56352ed6bebc736d1d |
|
BLAKE2b-256 | 3c3bb9a47066b7c07884036a9b31c17237b568698396e79777c39f1a32c402f6 |