Pytigergraph query updation

Hi @Szilard_Barany is there any way to save the query through the pytigergraph or gsql shell.
I have colab notebook were all the DDL commands and the queries are written. so i wanted to update the query in the notebook itself using pytigergraph library.

Hi @Ashraf ,

In the code below, we assumes that conn is a pyTigerGraph Connection object that is already initialized.

If you want to save the query through pyTigerGraph, you can try doing something like this:

conn.gsql("""
    USE GRAPH <graph-name>
    
    CREATE OR REPLACE QUERY <query-name> (<params...>) {
        ...
    }    
""")

You can use CREATE OR REPLACE QUERY <query-name> (<params...>) { format if you want a distributed query.

If you want to install the query, you can do this command:

conn.gsql("""
    USE GRAPH <graph-name>
    INSTALL QUERY <query-name>
""")

Or if you want to install multiple queries, you can do this:

conn.gsql("""
    USE GRAPH <graph-name>
    INSTALL QUERY <query-name-1>, <query-name-2>, ...
""")

Best,
Supawish Limprasert (Jim)
Solution Engineer, TigerGraph

Thanks @Jim_Limprasert

1 Like