Building Web Applications with Python and Neo4j

Book description

Develop exciting real-world Python-based web applications with Neo4j using frameworks such as Flask, Py2neo, and Django

In Detail

Py2neo is a simple and pragmatic Python library that provides access to the popular graph database Neo4j via its RESTful web service interface. This brings with it a heavily refactored core, a cleaner API, better performance, and some new idioms.

You will begin with licensing and installing Neo4j, learning the fundamentals of Cypher as a graph query language, and exploring Cypher optimizations. You will discover how to integrate with various Python frameworks such as Flask and its extensions: Py2neo, Neomodel, and Django. Finally, the deployment aspects of your Python-based Neo4j applications in a production environment is also covered. By sequentially working through the steps in each chapter, you will quickly learn and master the various implementation details and integrations of Python and Neo4j, helping you to develop your use cases more quickly.

What You Will Learn

  • Understand the licensing and installation of the Neo4j database and work with its various tools and utilities

  • Learn the intricacies of Cypher as a graph query language

  • Work with Cypher to create and modify graph data models

  • Integrate Python and Neo4j using Py2neo

  • Develop REST-based services over social network data using Flask and object graph models over Neo4j

  • Integrate Django-based web applications over graph data models using Neomodel

  • Explore different deployment models and their applicability with existing applications

  • Table of contents

    1. Building Web Applications with Python and Neo4j
      1. Table of Contents
      2. Building Web Applications with Python and Neo4j
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Your First Query with Neo4j
        1. Thinking in graphs for SQL developers
          1. Comparing SQL and Cypher
          2. Evolving graph structures from SQL models
        2. Licensing and configuring – Neo4j
          1. Licensing – Community Edition
          2. Licensing – Enterprise Edition
          3. Installing Neo4J Community Edition on Linux/Unix
            1. Installing as a Linux tar / standalone application
            2. Installing as a Linux service
          4. Installing Neo4j Enterprise Edition on Unix/Linux
        3. Using the Neo4j shell
        4. Introducing the Neo4j REST interface
          1. Authorization and authentication
          2. CRUD operations
        5. Running queries from the Neo4j browser
        6. Summary
      9. 2. Querying the Graph with Cypher
        1. Basic anatomy of a Cypher query
          1. Brief details of Cypher
          2. Cypher execution phases
            1. Parsing, validating, and generating the execution plan
            2. Locating the initial node(s)
            3. Selecting and traversing the relationships
            4. Changing and/or returning the values
          3. The structure of Cypher
            1. The read operations
              1. MATCH
              2. OPTIONAL MATCH
              3. START
              4. AGGREGATION
            2. The create or update operations
              1. Create
              2. SET
              3. MERGE
            3. The delete operation
        2. Pattern and pattern matching
          1. Sample dataset
          2. Pattern for nodes
          3. Pattern for labels
          4. Pattern for relationships
          5. Pattern for properties
          6. Using the where clause with patterns
            1. Using patterns in the where clause
          7. Using general clauses with patterns
            1. The order by clause
            2. The limit and skip clauses
            3. The WITH clause
            4. The UNION and UNION ALL clauses
          8. Working with nodes and relationships
        3. Summary
      10. 3. Mutating Graph with Cypher
        1. Creating nodes and relationships
          1. Working with nodes
            1. Single node
            2. Multiple nodes
            3. Node with labels
            4. Node with properties
          2. Working with relationships
            1. Single relationships
            2. Multiple relationships
            3. Relationships with properties
          3. Nodes and relationships with full paths
          4. Creating unique nodes and relationships
          5. CREATE UNIQUE and MERGE
          6. Working with constraints
        2. Transforming nodes and relationships
          1. Updating node properties
          2. Updating a label
          3. Updating relationships
        3. Cypher query optimizations
          1. Indexes
            1. Index sampling
          2. Understanding execution plans
          3. Analyzing and optimizing queries
        4. Summary
      11. 4. Getting Python and Neo4j to Talk Py2neo
        1. Installing and configuring py2neo
          1. Prerequisites
          2. Installing py2neo
        2. Exploring the py2neo APIs
          1. Graph
          2. Authentication
          3. Node
          4. Relationship
          5. Cypher
          6. Transactions
          7. Paths
        3. Creating a social network with py2neo
        4. Batch imports
        5. Unit testing
        6. Summary
      12. 5. Build RESTful Service with Flask and Py2neo
        1. Introducing (and installing) Flask
        2. Setting up web applications with Flask and Flask-RESTful
          1. Your first Flask application
            1. Displaying static content
            2. Displaying dynamic content
          2. Your first Flask RESTful API
            1. JSON processing
        3. REST APIs for social network data using py2neo
          1. ORM for graph databases py2neo – OGM
          2. Social network application with Flask-RESTful and OGM
            1. Creating object model
            2. Creating REST APIs over data models
        4. Summary
      13. 6. Using Neo4j with Django and Neomodel
        1. Installing and configuring Neomodel
        2. Declaring models and properties
          1. Defining nodes
          2. Defining properties
          3. Persisting and querying a social data model
        3. Adding relationships to models
        4. Running Cypher queries
        5. Using Neomodel in a Django app
          1. Signals in Neomodel
        6. Summary
      14. 7. Deploying Neo4j in Production
        1. Neo4j logical architecture
          1. Disk/filesystem
          2. Record files
          3. Transaction logs
          4. Caches
          5. Core Java API
          6. Traversal framework
          7. REST API
        2. Neo4j physical architecture
          1. High availability
          2. Fault tolerance
          3. Data replication and data locality
          4. Advanced settings
        3. Monitoring the health of the Neo4J nodes
          1. Neo4j browser
          2. Webadmin
          3. JMX beans
        4. Backup and recovery
        5. Summary
      15. Index

    Product information

    • Title: Building Web Applications with Python and Neo4j
    • Author(s): Sumit Gupta
    • Release date: July 2015
    • Publisher(s): Packt Publishing
    • ISBN: 9781783983988