Search code examples
memgraphdb

How to use mgconsole non-interactive mode to run queries?


Is it possible to run queries in mgconsole non-interactively? I know that I can use a file that has query in it and redirect it, mgconsole < test.txt. I would like to avoid creating a file on a filesystem.

How can I pass Cypher query to mgconsole?


Solution

  • If you don't want to use file for input you can use echo in combination with pipe, e.g.

    echo "MATCH (n) RETURN n;" | mgconsole