Skip to content

Instantly share code, notes, and snippets.

@jalakoo
Created August 20, 2025 22:33
Show Gist options
  • Select an option

  • Save jalakoo/9e0ff836bc75e1a2b9945baf2eede4c4 to your computer and use it in GitHub Desktop.

Select an option

Save jalakoo/9e0ff836bc75e1a2b9945baf2eede4c4 to your computer and use it in GitHub Desktop.
Neo4j Intro To Python Code
from neo4j import GraphDatabase
# Read-only credentials
URI = "neo4j+s://demo.neo4jlabs.com"
USERNAME = "goodreads"
PASSWORD = "goodreads"
DATABASE = "goodreads"
def main(query, params):
with GraphDatabase.driver(URI, auth=(USERNAME, PASSWORD)) as driver:
records, summary, keys = driver.execute_query(
query,
parameters_ = params,
database_ = DATABASE
)
return [record.data() for record in records]
if __name__ == "__main__":
import json
query = """
MERGE (b:Book {title: $title})
RETURN b.title as title
LIMIT $limit
"""
params = {
"title": "The Great Gatsby",
"limit": 10
}
result = main(query, params)
print(json.dumps(result, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment