SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
Python and Neo4j
Eric Lee

Silicon Cloud International Pte Ltd
2015.DEC.17

@Singapore Neo4j Meetup
About Me
Eric Lee
NoSQL
Silicon Cloud
International
:Love
:EMPLOYEE_OF
Secured
Private Cloud
:PROVIDES
Neo4j
Cassandra
:IS
:IS
Python Perl JavaScript
:PROGRAMMING_IN
:PROGRAMMING_IN
:PROGRAMMING_IN
Start Your Neo4j Server
• Install Oracle JDK 8
• Download Neo4j Enterprise or Community edition
• Unzip it
• In Neo4j directory, execute this command:

./bin/neo4j start
Python Libraries for Neo4j
• Py2neo

Good performance for great amounts of nodes.
• neo4j-rest-client

If only a few nodes, use this REST based client.
• neo4jdb-python

Mainly for Cypher syntax manipulation.
Py2neo
• Installation

pip install py2neo
Authentication
• Before Neo4j 2.2

from py2neo import graph

graph = Graph()



Default is “http://127.0.0.1:7474/db/data”
• Neo4j 2.2/2.3, you need authentication

from py2neo import graph

graph = Graph(“http://neo4j:test@127.0.0.1:7474/db/data”)

Username Password
neo4j-server.properties
Uncomment this line for remote access
Replace “true” by “false” to disable authentication
Create Node
• Create node with label and properties

from py2neo import Graph, Node

graph = Graph(…)





Node1 = Node(“User”, Name=“Eric”, Gender=“M”)





graph.create(Node1)
Label Properties
Create Relationship
• One to one relationship

from py2neo import Graph, Node, Relationship

graph = Graph(…)

eric = Node(“User”, Name=“Eric”, Gender=“M”)

sci = Node(“Company”, Name=“Silicon Cloud Intl”)

ericWorkInsci = Relationship(eric,”WORK_IN”,sci,Since=2015)

graph.create(ericWorkInsci)
 Relationship Name Relationship Property
CREATE (User{Name:”Eric”…})-[:WORK_IN{Since:2015}]->(Company{Name:”Silicon Cloud Intl”})
Search
• Find One Node

graph.find_one(“User”,”Name”,”Eric”)
• Return all Nodes

results = graph.find(“User”, “Name”,”Eric”)

# will return an object



for result in results:

print result
Label Property Value
Modify Properties
• Add Property

eric = graph.find_one(“User”, “Name”, “Eric”)



eric.properties[“Surname”] = “Lee”



eric.push()

Delete
• Specific Objects

eric = graph.find_one(“User”, “Name”, “Eric”)



eric.delete()
• All nodes and relationships

graph.delete_all()

Easy than “MATCH (n)-[r]-(q) DELETE n,r,q”
Uniqueness
• Unique nodes

graph.schema.create_uniqueness_constraint("User", “Employee_ID”)



#Set the constraint first



eric = graph.merge_one(“User”, “Employee_ID”, “0007” )
• Unique Paths

eric = graph.merge_one(“User”, “Employee_ID”, “0007” )



mojy = graph.merge_one(“User”, “Employee_ID”, “0001” )



graph.create_unique(Relationship(mojy,”RECRUITS”,eric))

Submit Cypher Queries
• Submit qualified Cypher Syntax

graph.cypher.execute(cypher syntax string)
Return a list, to access each element, you can create a for loop.
Reference
• http://py2neo.org/2.0/intro.html
• http://www.slideshare.net/fphhotchips/a-quick-
review-of-python-and-graph-databases
• http://www.slideshare.net/leezhenyu/introduction-
to-graph-database

Mais conteúdo relacionado

Mais procurados

[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
CODE BLUE
 
Tailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ NeedsTailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ Needs
Redis Labs
 

Mais procurados (20)

Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)
 
Hopsworks - Self-Service Spark/Flink/Kafka/Hadoop
Hopsworks - Self-Service Spark/Flink/Kafka/HadoopHopsworks - Self-Service Spark/Flink/Kafka/Hadoop
Hopsworks - Self-Service Spark/Flink/Kafka/Hadoop
 
[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
[CB16] DeathNote of Microsoft Windows Kernel by Peter Hlavaty & Jin Long
 
H-Hypermap - Heatmap Analytics at Scale: Presented by David Smiley, D W Smile...
H-Hypermap - Heatmap Analytics at Scale: Presented by David Smiley, D W Smile...H-Hypermap - Heatmap Analytics at Scale: Presented by David Smiley, D W Smile...
H-Hypermap - Heatmap Analytics at Scale: Presented by David Smiley, D W Smile...
 
Bullet: A Real Time Data Query Engine
Bullet: A Real Time Data Query EngineBullet: A Real Time Data Query Engine
Bullet: A Real Time Data Query Engine
 
Mobile Analytics mit Elasticsearch und Kibana
Mobile Analytics mit Elasticsearch und KibanaMobile Analytics mit Elasticsearch und Kibana
Mobile Analytics mit Elasticsearch und Kibana
 
Improved Applications with IPv6: an overview
Improved Applications with IPv6: an overviewImproved Applications with IPv6: an overview
Improved Applications with IPv6: an overview
 
Neo4j Data Loading with Kettle
Neo4j Data Loading with KettleNeo4j Data Loading with Kettle
Neo4j Data Loading with Kettle
 
Open Source Logging and Monitoring Tools
Open Source Logging and Monitoring ToolsOpen Source Logging and Monitoring Tools
Open Source Logging and Monitoring Tools
 
fluentd -- the missing log collector
fluentd -- the missing log collectorfluentd -- the missing log collector
fluentd -- the missing log collector
 
Smart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVecSmart Data Conference: DL4J and DataVec
Smart Data Conference: DL4J and DataVec
 
Logging logs with Logstash - Devops MK 10-02-2016
Logging logs with Logstash - Devops MK 10-02-2016Logging logs with Logstash - Devops MK 10-02-2016
Logging logs with Logstash - Devops MK 10-02-2016
 
Tailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ NeedsTailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ Needs
 
StormCrawler in the wild
StormCrawler in the wildStormCrawler in the wild
StormCrawler in the wild
 
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
Policy-based Resource Placement Across Hybrid Cloud
Policy-based Resource Placement Across Hybrid CloudPolicy-based Resource Placement Across Hybrid Cloud
Policy-based Resource Placement Across Hybrid Cloud
 
Protecting the Data Lake
Protecting the Data LakeProtecting the Data Lake
Protecting the Data Lake
 
Using the flipn stack for edge ai (flink, nifi, pulsar)
Using the flipn stack for edge ai (flink, nifi, pulsar)Using the flipn stack for edge ai (flink, nifi, pulsar)
Using the flipn stack for edge ai (flink, nifi, pulsar)
 
HDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon KimHDFS on Kubernetes—Lessons Learned with Kimoon Kim
HDFS on Kubernetes—Lessons Learned with Kimoon Kim
 

Destaque (7)

COSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jCOSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4j
 
SNP Detection for Massively Parallel Whole-genome Sequencing
SNP Detection for Massively Parallel Whole-genome SequencingSNP Detection for Massively Parallel Whole-genome Sequencing
SNP Detection for Massively Parallel Whole-genome Sequencing
 
Neo4j: JDBC Connection Case Using LibreOffice
Neo4j: JDBC Connection Case Using LibreOfficeNeo4j: JDBC Connection Case Using LibreOffice
Neo4j: JDBC Connection Case Using LibreOffice
 
Introduction to 3rd sequencing
Introduction to 3rd sequencing Introduction to 3rd sequencing
Introduction to 3rd sequencing
 
Introduction to Graph Database
Introduction to Graph DatabaseIntroduction to Graph Database
Introduction to Graph Database
 
Google MAP API
Google MAP APIGoogle MAP API
Google MAP API
 
R3 Corda Simple Tutorial
R3 Corda Simple TutorialR3 Corda Simple Tutorial
R3 Corda Simple Tutorial
 

Semelhante a Python and Neo4j

GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
Neo4j
 
Training Week: Build APIs with Neo4j GraphQL Library
Training Week: Build APIs with Neo4j GraphQL LibraryTraining Week: Build APIs with Neo4j GraphQL Library
Training Week: Build APIs with Neo4j GraphQL Library
Neo4j
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
LeanDog
 

Semelhante a Python and Neo4j (20)

Neo4j python
Neo4j pythonNeo4j python
Neo4j python
 
Introduction to Neo4j APOC
Introduction to Neo4j APOCIntroduction to Neo4j APOC
Introduction to Neo4j APOC
 
GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
GraphDay Paris - Intégrer des flux de données dans Neo4j avec l'ETL Open Sour...
 
Operating Neo4j Fabric in Multi-Zone Kubernetes Cluster.pptx
Operating Neo4j Fabric in Multi-Zone Kubernetes Cluster.pptxOperating Neo4j Fabric in Multi-Zone Kubernetes Cluster.pptx
Operating Neo4j Fabric in Multi-Zone Kubernetes Cluster.pptx
 
Leveraging docker for hadoop build automation and big data stack provisioning
Leveraging docker for hadoop build automation and big data stack provisioningLeveraging docker for hadoop build automation and big data stack provisioning
Leveraging docker for hadoop build automation and big data stack provisioning
 
Leveraging Docker for Hadoop build automation and Big Data stack provisioning
Leveraging Docker for Hadoop build automation and Big Data stack provisioningLeveraging Docker for Hadoop build automation and Big Data stack provisioning
Leveraging Docker for Hadoop build automation and Big Data stack provisioning
 
Training Week: Build APIs with Neo4j GraphQL Library
Training Week: Build APIs with Neo4j GraphQL LibraryTraining Week: Build APIs with Neo4j GraphQL Library
Training Week: Build APIs with Neo4j GraphQL Library
 
Road to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache HopRoad to NODES - Handling Neo4j Data with Apache Hop
Road to NODES - Handling Neo4j Data with Apache Hop
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015
 
Supercharge Your Real-time Event Processing with Neo4j's Streams Kafka Connec...
Supercharge Your Real-time Event Processing with Neo4j's Streams Kafka Connec...Supercharge Your Real-time Event Processing with Neo4j's Streams Kafka Connec...
Supercharge Your Real-time Event Processing with Neo4j's Streams Kafka Connec...
 
Neo4j Import Webinar
Neo4j Import WebinarNeo4j Import Webinar
Neo4j Import Webinar
 
FIWARE Global Summit - Building Your Own IoT Agent
FIWARE Global Summit - Building Your Own IoT AgentFIWARE Global Summit - Building Your Own IoT Agent
FIWARE Global Summit - Building Your Own IoT Agent
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & docker
 
Master Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache KafkaMaster Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache Kafka
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
 
A Byte of Software Deployment
A Byte of Software DeploymentA Byte of Software Deployment
A Byte of Software Deployment
 
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
 
Docker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know nowDocker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know now
 
Mastering Terraform and the Provider for OCI
Mastering Terraform and the Provider for OCIMastering Terraform and the Provider for OCI
Mastering Terraform and the Provider for OCI
 
Neo4j GraphConnect summary
Neo4j GraphConnect summaryNeo4j GraphConnect summary
Neo4j GraphConnect summary
 

Último

Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 

Último (20)

BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 

Python and Neo4j

  • 1. Python and Neo4j Eric Lee
 Silicon Cloud International Pte Ltd 2015.DEC.17
 @Singapore Neo4j Meetup
  • 2. About Me Eric Lee NoSQL Silicon Cloud International :Love :EMPLOYEE_OF Secured Private Cloud :PROVIDES Neo4j Cassandra :IS :IS Python Perl JavaScript :PROGRAMMING_IN :PROGRAMMING_IN :PROGRAMMING_IN
  • 3. Start Your Neo4j Server • Install Oracle JDK 8 • Download Neo4j Enterprise or Community edition • Unzip it • In Neo4j directory, execute this command:
 ./bin/neo4j start
  • 4. Python Libraries for Neo4j • Py2neo
 Good performance for great amounts of nodes. • neo4j-rest-client
 If only a few nodes, use this REST based client. • neo4jdb-python
 Mainly for Cypher syntax manipulation.
  • 6. Authentication • Before Neo4j 2.2
 from py2neo import graph
 graph = Graph()
 
 Default is “http://127.0.0.1:7474/db/data” • Neo4j 2.2/2.3, you need authentication
 from py2neo import graph
 graph = Graph(“http://neo4j:test@127.0.0.1:7474/db/data”)
 Username Password
  • 7. neo4j-server.properties Uncomment this line for remote access Replace “true” by “false” to disable authentication
  • 8. Create Node • Create node with label and properties
 from py2neo import Graph, Node
 graph = Graph(…)
 
 
 Node1 = Node(“User”, Name=“Eric”, Gender=“M”)
 
 
 graph.create(Node1) Label Properties
  • 9. Create Relationship • One to one relationship
 from py2neo import Graph, Node, Relationship
 graph = Graph(…)
 eric = Node(“User”, Name=“Eric”, Gender=“M”)
 sci = Node(“Company”, Name=“Silicon Cloud Intl”)
 ericWorkInsci = Relationship(eric,”WORK_IN”,sci,Since=2015)
 graph.create(ericWorkInsci)
 Relationship Name Relationship Property CREATE (User{Name:”Eric”…})-[:WORK_IN{Since:2015}]->(Company{Name:”Silicon Cloud Intl”})
  • 10. Search • Find One Node
 graph.find_one(“User”,”Name”,”Eric”) • Return all Nodes
 results = graph.find(“User”, “Name”,”Eric”)
 # will return an object
 
 for result in results:
 print result Label Property Value
  • 11. Modify Properties • Add Property
 eric = graph.find_one(“User”, “Name”, “Eric”)
 
 eric.properties[“Surname”] = “Lee”
 
 eric.push()

  • 12. Delete • Specific Objects
 eric = graph.find_one(“User”, “Name”, “Eric”)
 
 eric.delete() • All nodes and relationships
 graph.delete_all()
 Easy than “MATCH (n)-[r]-(q) DELETE n,r,q”
  • 13. Uniqueness • Unique nodes
 graph.schema.create_uniqueness_constraint("User", “Employee_ID”)
 
 #Set the constraint first
 
 eric = graph.merge_one(“User”, “Employee_ID”, “0007” ) • Unique Paths
 eric = graph.merge_one(“User”, “Employee_ID”, “0007” )
 
 mojy = graph.merge_one(“User”, “Employee_ID”, “0001” )
 
 graph.create_unique(Relationship(mojy,”RECRUITS”,eric))

  • 14. Submit Cypher Queries • Submit qualified Cypher Syntax
 graph.cypher.execute(cypher syntax string) Return a list, to access each element, you can create a for loop.