DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • The SPACE Framework for Developer Productivity
  1. DZone
  2. Data Engineering
  3. Databases
  4. Building a Python Web Application Using Flask and Neo4j

Building a Python Web Application Using Flask and Neo4j

Andreas Kollegger user avatar by
Andreas Kollegger
·
Feb. 02, 15 · Interview
Like (0)
Save
Tweet
Share
6.78K Views

Join the DZone community and get the full member experience.

Join For Free

flask, a popular python web framework, has many tutorials available online which use an sql database to store information about the website’s users and their activities.  while sql is a great tool for storing information such as usernames and passwords, it is not so great at allowing you to find connections among your users for the purposes of enhancing your website’s social experience.

the quickstart flask tutorial builds a microblog application using sqlite. in my tutorial , i walk through an expanded, neo4j-powered version of this microblog application that uses py2neo , one of neo4j’s python drivers, to build social aspects into the application. this includes recommending similar users to the logged-in user, along with displaying similarities between two users when one user visits another user’s profile.

my microblog application consists of users, posts, and tags modeled in neo4j:

http://i.imgur.com/9nuvbpz.png

with this graph model, it is easy to ask questions such as:

“what are the top tags of posts that i’ve liked?”

match (me:user)-[:liked]->(post:post)<-[:tagged]-(tag:tag)
where me.username = 'nicole'
return tag.name, count(*) as count
order by count desc
“which user is most similar to me based on tags we’ve both posted about?”
match (me:user)-[:published]->(:post)<-[:tagged]-(tag:tag), (other:user)-[:published]->(:post)<-[:tagged]-(tag)
where me.username = 'nicole' and me <> other
with other,

    collect(distinct tag.name) as tags,
    count(distinct tag) as len

order by len desc limit 3
return other.username as similar_user, tags 
links to the full walkthrough of the application and the complete code are below.
      tutorial
      github
if you would like a live walkthrough, be sure to register for my upcoming webinar on building a python web application with flask and neo4j.

Web application Python (language) Neo4j Flask (web framework)

Published at DZone with permission of Andreas Kollegger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • The SPACE Framework for Developer Productivity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: