Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-21-2022 07:04 AM
Hi,
I need to create and use a database via the http endpoint. creating works but it still uses the default database (neo4j). When I try to use ":USE NAME" via http it complains that a ":" is not valid. But I need to create many different databases and use them... any idea how to solve this? Maybe I have the wrong url?
My url is:
"http://localhost:11006/db/data/transaction/commit"
That is the Error Message:
{"results"=>[], "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Invalid input ':': expected <init> (line 1, column 1 (offset: 0))\r\n\":USE Nemo13\"\r\n ^"}]}
That is the part of my script:
#creates Database in neo4j, if not exists --> works
caseName = currentCase.getName
payload = { "statements": [{ "statement": "CREATE DATABASE #{caseName}" }]}
returnValue = Client.post(url, headers, payload, use_ssl)
#uses that database --> error
string = ":USE #{caseName}"
puts string # Nemo13
payload = { "statements": [{ "statement": "#{string}"}]}
returnValue = Client.post(url, headers, payload, use_ssl)
puts returnValue # {"results"=>[], "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Invalid input ':': expected <init> (line 1, column 1 (offset: 0))\r\n\":USE Nemo13\"\r\n ^"}]}
09-21-2022 07:53 AM
try without the colon. I was able to do so in browser.
09-21-2022 11:51 PM
that did not work. now i get this error message:
{"results"=>[], "errors"=>[{"code"=>"Neo.ClientError.Statement.SyntaxError", "message"=>"Query cannot conclude with USE GRAPH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD) (line 1, column 1 (offset: 0))\r\n\"USE Nemo13\"\r\n ^"}]}
but thanks anyway
09-22-2022 01:53 AM
It looks like you are using the statement by itself. Try inserting it at the beginning of each query to specify the database to use for that query.
09-22-2022 02:06 AM
Yes 🙂 That solved the issue. Many thanks
All the sessions of the conference are now available online