简体   繁体   中英

Is there any way i can run cypher command starting from :Param using py2neo 2021.0.0

Well, in neo4j i am trying to achieve this simple query to save the sparql keyword to use in later query and graph.run is not allowing me to do it. It is showing a syntax error

graph.run(":PARAM sparql: 'PREFIX sch: <http://schema.org/> CONSTRUCT{?item a sch:item; sch:legalIdentity ?legalIdentity} WHERE { {?item p:P31/ps:P31 wd:Q783794 optional { ?item wdt:P1278 ?legalIdentity} } UNION {?item p:P31/ps:P31 wd:Q4830453 optional { ?item wdt:P1278 ?legalIdentity}} UNION {?item p:P31/ps:P31 wd:Q43229 optional { ?item wdt:P1278 ?legalIdentity}} UNION {?item p:P31/ps:P31 wd:Q6881511 optional { ?item wdt:P1278 ?legalIdentity}}}'")

And following line is the cypher query which uses sparql keyword

graph.run('CALL n10s.rdf.import.fetch("https://query.wikidata.org/sparql?query=" + apoc.text.urlencode($sparql), "RDF/XML", { headerParams: { Accept: "application/rdf+xml"} });')

The :PARAM command is a client-side browser/shell built-in. It does not exist in Cypher itself. As mentioned by @fbiville , you will need to pass a dict of parameters instead.

You can pass a dictionary of parameters to the run method, as documented here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM