{"id":3375,"date":"2018-05-31T17:35:36","date_gmt":"2018-05-31T17:35:36","guid":{"rendered":"https:\/\/max-drake.cc\/?p=3375"},"modified":"2018-05-31T17:35:36","modified_gmt":"2018-05-31T17:35:36","slug":"python-10-neo4j-graph-database-py2neo","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=3375","title":{"rendered":"Python 10. Neo4j Graph Database &#038; Py2neo"},"content":{"rendered":"<p>The community edition download on the Neo4j&nbsp; website is<a href=\"https:\/\/neo4j.com\/download\/other-releases\/\" target=\"_blank\" rel=\"noopener\"><strong> here<\/strong><\/a>.&nbsp; After downloading the particular version you want in ZIP format it takes you to a <a href=\"https:\/\/neo4j.com\/download-thanks-beta\/?edition=community&amp;release=3.5.0-alpha01&amp;architecture=x32\" target=\"_blank\" rel=\"noopener\"><strong>page<\/strong><\/a> that offers a free book and the instructions for installing.<\/p>\n<p>For basic overview and setting up Neo4j community edition ( older version from an EXE ) I watched the following video series:<\/p>\n<p><iframe title=\"NoSQL: Getting Started with Neo4j and Cypher\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/videoseries?list=PLAWPhrZnH759YHRieMBzsQRvr56JcYx5l\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>I found this video useful. It is created by the same person who did the beginners MongoDB tutorial, he gives you all the basic code to make an initial start.<\/p>\n<p><iframe title=\"Neo4j Graph Database &amp; Cypher\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/1kyPUqU-MkE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>This one is quite advanced but good in showing where to get a good dataset to practice. The arrows examples I think were just a&nbsp; <a href=\"https:\/\/github.com\/apcj\/arrows\" target=\"_blank\" rel=\"noopener\">diagrammatic example<\/a>.&nbsp;<\/p>\n<p><iframe title=\"Working With a Real-World Dataset in Neo4j - Import and Modeling\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/oXziS-PPIUA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>So for the install, I located my instance in C:\\neo4j\\bin. I used the latest zip file and moved it to that location.&nbsp; I also had my database there under&nbsp; C:\\neo4j\\data\\databases\\graph.db.<\/p>\n<p>I started the COMMAND prompt in Administration mode and moved to the C:\\neo4j\\bin and then ran the :<\/p>\n<p>&#8216;&gt; neo4j console [enter]\n<p>That started the server instance of Neo4j on my computer, then I went to my web browser and put in:<\/p>\n<p><strong>http:\/\/localhost:7474\/browser\/<\/strong><\/p>\n<p>That brought up my instance for working in neo4j.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-3381 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03-1024x631.jpg\" alt=\"\" width=\"1423\" height=\"877\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03-1024x631.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03-300x185.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03-768x473.jpg 768w\" data-sizes=\"(max-width: 1423px) 100vw, 1423px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1423px; --smush-placeholder-aspect-ratio: 1423\/877;\" \/><\/p>\n<p><img decoding=\"async\" class=\"wp-image-3386 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn01-1024x512.jpg\" alt=\"\" width=\"1446\" height=\"723\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn01-1024x512.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn01-300x150.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn01-768x384.jpg 768w\" data-sizes=\"(max-width: 1446px) 100vw, 1446px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1446px; --smush-placeholder-aspect-ratio: 1446\/723;\" \/><\/p>\n<p><img decoding=\"async\" class=\"wp-image-3385 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn02-441x1024.jpg\" alt=\"\" width=\"848\" height=\"1969\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn02-441x1024.jpg 441w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn02-129x300.jpg 129w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn02.jpg 730w\" data-sizes=\"(max-width: 848px) 100vw, 848px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 848px; --smush-placeholder-aspect-ratio: 848\/1969;\" \/><\/p>\n<p><img decoding=\"async\" class=\"wp-image-3384 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn04-588x1024.jpg\" alt=\"\" width=\"837\" height=\"1458\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn04-588x1024.jpg 588w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn04-172x300.jpg 172w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn04.jpg 686w\" data-sizes=\"(max-width: 837px) 100vw, 837px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 837px; --smush-placeholder-aspect-ratio: 837\/1458;\" \/><\/p>\n<p><img decoding=\"async\" class=\"wp-image-3383 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn05.jpg\" alt=\"\" width=\"845\" height=\"444\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn05.jpg 950w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn05-300x158.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn05-768x403.jpg 768w\" data-sizes=\"(max-width: 845px) 100vw, 845px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 845px; --smush-placeholder-aspect-ratio: 845\/444;\" \/> <img decoding=\"async\" class=\"wp-image-3382 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn06-1024x494.jpg\" alt=\"\" width=\"1485\" height=\"716\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn06-1024x494.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn06-300x145.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn06-768x371.jpg 768w\" data-sizes=\"(max-width: 1485px) 100vw, 1485px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1485px; --smush-placeholder-aspect-ratio: 1485\/716;\" \/><\/p>\n<p>So, I put in some nodes for Site, Block, Unit &amp; Rooms. Also made one way connectors using CONTAINS as a relationship from&nbsp; &nbsp;&nbsp; Site to Block, Block to Unit, Unit to Rooms.<\/p>\n<p>I am not sure that there is much point in putting in a reverse relationship of &#8220;CONTAINED IN&#8221;. \\<\/p>\n<p>My next challenge is to upload a lot of data into the Database. I have some CSV data in SPM format that I may try and upload. I&#8217;m not sure that this is the right data set to use as its pretty hierarchical.<\/p>\n<h3>Python &amp; Neo4j<\/h3>\n<p><iframe title=\"Graph Databases for Python Users\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/3JMhX1sT98U?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>Nicole White, Chief Data Scientist, Neo Technology:Learn how to use Python to collect data from Twitter\u2019s API, Neo4j to easily and reliably store this highly-connected data, and Python again for quick analysis and visualization. Follow along with these resources &#8211;<\/p>\n<p>1) nicolewhite.github.io\/neo4j-jupyter\/<strong>hello-world.html<\/strong><\/p>\n<p>I had to alter the code in PyCharm to give Graph some connection details to Neo4j but apart from that the code ran great and created the nodes in Neo4j on my local server.<\/p>\n<p>I also moved the existing&nbsp; graph.db from C:\\neo4j\\data\\databases\\graph.db to C:\\neo4j\\OLDDB\\graph.db as I didn&#8217;t want to delete the work I&#8217;d already done.<\/p>\n<p>I still have not figured out how to create a completelty new DB. But that can be for later.<\/p>\n<p>So I now have a connection between Python and Neo4j. So can write and create nodes and relationships in neo4j from python and also do some graphing in Python now I have the connection.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-3389 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn08-1024x428.jpg\" alt=\"\" width=\"1447\" height=\"604\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn08-1024x428.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn08-300x125.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn08-768x321.jpg 768w\" data-sizes=\"(max-width: 1447px) 100vw, 1447px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1447px; --smush-placeholder-aspect-ratio: 1447\/604;\" \/><\/p>\n<p><img decoding=\"async\" class=\"wp-image-3388 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn07-1024x468.jpg\" alt=\"\" width=\"1472\" height=\"673\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn07-1024x468.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn07-300x137.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn07-768x351.jpg 768w\" data-sizes=\"(max-width: 1472px) 100vw, 1472px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1472px; --smush-placeholder-aspect-ratio: 1472\/673;\" \/><\/p>\n<p>2) nicolewhite.github.io\/neo4j-jupyter\/twitter.html<\/p>\n<p>3) github.com\/nicolewhite\/neo4j-jupyter<\/p>\n<p>There is this video below by the same person in the video above. I have not tested any of the things she is demonstrating yet.<\/p>\n<p><iframe title=\"Using Python and Neo4j for Data Analytics | Nicole White, Data Scientist at Neo4j\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/Nkd6Ei-xuxI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<h3><strong>End thoughts<\/strong><\/h3>\n<p>Now I have Neo4j up and running and a python connection I will think about developing this to see if I can use it in the property asset environment. I need to do a bit of searching on the web to see if there are any examples.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The community edition download on the Neo4j&nbsp; website is here.&nbsp; After downloading the particular version you want in ZIP format it takes you to a page that offers a free book and the instructions for installing. For basic overview and setting up Neo4j community edition ( older version from an EXE ) I watched the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3381,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,34],"tags":[],"class_list":["post-3375","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nosql-databases","category-python"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2018\/05\/imn03.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/3375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3375"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/3375\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/3381"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}