Company
Date Published
Author
Stuart Green
Word count
686
Language
English
Hacker News points
None

Summary

In this article, we explore how to use Tcl's HTTP functionality to query a graph database via the Neo4j Query API. To make/secure HTTP requests and handle the JSON payload, additional packages are required, including tcllib, tcl-tls, json::write, and json. We define a procedure `neo4j_query` that performs the Cypher query and returns the result as a dictionary. The procedure takes two arguments: `cypher`, which defines the graph database query, and `db`, which holds the Neo4j settings. We create a dictionary to hold the Neo4j settings and use this with the Cypher query string to call the `neo4j_query` procedure. The returned dictionary contains two keys: `values` and `fields`. We provide an example using the Northwind database hosted on a Neo4j demo server, identifying all products in the 'Dairy Products' category.