Gsql installation

Hi there,

I created a number of queries for my graph “MyGraph” and put all of them in the “myQueries” dir. I know I can write a scrip to do gsql -g MyGraph myQueries/query1.gsql … one by one, but to simplify the process, is there a way to install ALL gsql queries inside a dir? *.gsql doesn’t seem to work.

Thanks,
John

@John_Chen Assuming all your queries have been created already. You can run the GSQL command:
INSTALL QUERY * or INSTALL QUERY ALL

Documentation Reference:
https://docs.tigergraph.com/v/3.0/dev/gsql-ref/querying/query-operations#install-query

@John_Chen can you try this please

cat myQueries/*.gsql | gsql -g MyGraph

or this one ( both should work )

cd myQueries && for %S in (*.gsql) do gsql -g MyGraph < %S

Hi @Jon_Herke, thanks for the quick response. This step is before INSTALL QUERY *, this is to CREATE QUERY....

Hi @Mohamed_Zrouga, it is a promising idea, but didn’t work – the error message:

GSQL > }CREATE QUERY SystemFailureImpact(string vertexType, vertex input) FOR GRAPH PEArchDemo {
Encountered " "}" "} "" at line 1, column 1.
Was expecting one of:
    "@" ... 

use this one instead
cd myQueries && for %S in (*.gsql) do gsql -g PEArchDemo < %

But i see that your gsql says for GRAPH PEArchDemo

1 Like

Thanks @Mohamed_Zrouga for the tip, the following works:

for gsql_file in myQueries/*.gsql; do gsql -g MyGraph $gsql_file; done

I appreciate the quick responses!

John

2 Likes