Skip to content

Commit

Permalink
add setup tip
Browse files Browse the repository at this point in the history
  • Loading branch information
CShorten committed Jan 28, 2025
1 parent eb5250f commit 704eaab
Showing 1 changed file with 9 additions and 53 deletions.
62 changes: 9 additions & 53 deletions notebooks/memgraph-pydantic-simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,15 @@
]
},
{
"cell_type": "code",
"execution_count": 4,
"cell_type": "markdown",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"John\n",
"{'labels_added': 1, 'labels_removed': 0, 'nodes_created': 1, 'nodes_deleted': 0, 'properties_set': 0, 'relationships_created': 0, 'relationships_deleted': 0}\n",
"John\n",
"MATCH (u:User {name: $name}) RETURN u.name AS name\n"
]
}
],
"source": [
"from neo4j import GraphDatabase\n",
" \n",
"# Define correct URI and AUTH arguments (no AUTH by default)\n",
"URI = \"bolt://localhost:7687\"\n",
"AUTH = (\"\", \"\")\n",
" \n",
"with GraphDatabase.driver(URI, auth=AUTH) as client:\n",
" # Check the connection\n",
" client.verify_connectivity()\n",
" \n",
" # Create a user in the database\n",
" records, summary, keys = client.execute_query(\n",
" \"CREATE (u:User {name: $name, password: $password}) RETURN u.name AS name;\",\n",
" name=\"John\",\n",
" password=\"pass\",\n",
" database_=\"memgraph\",\n",
" )\n",
" \n",
" # Get the result\n",
" for record in records:\n",
" print(record[\"name\"])\n",
" \n",
" # Print the query counters\n",
" print(summary.counters)\n",
" \n",
" # Find a user John in the database\n",
" records, summary, keys = client.execute_query(\n",
" \"MATCH (u:User {name: $name}) RETURN u.name AS name\",\n",
" name=\"John\",\n",
" database_=\"memgraph\",\n",
" )\n",
" \n",
" # Get the result\n",
" for record in records:\n",
" print(record[\"name\"])\n",
" \n",
" # Print the query\n",
" print(summary.query)"
"Run MemGraph with docker:\n",
"\n",
"```bash\n",
"curl https://install.memgraph.com | sh\n",
"docker run -it memgraph/mgconsole:latest [--host HOST_IP] [--port PORT]\n",
"```"
]
},
{
Expand Down Expand Up @@ -225,6 +180,7 @@
"# Verify the data\n",
"records, summary, keys = client.execute_query(\n",
" \"\"\"\n",
" MATCH (p:Person)-[r]->(n)\n",
" RETURN p.name as person, type(r) as relationship, n.name as target\n",
" \"\"\",\n",
" database_=\"memgraph\"\n",
Expand Down Expand Up @@ -503,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.undefined.undefined"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 704eaab

Please sign in to comment.