When I run the gsql command SHOW QUERY <query name>
I get the output back with leading space eliminated from all lines, so that all of the indentation is lost. Is there a way to get back the query as it was saved?
Maybe try another editor/terminal? I am using VSCode and my output correctly preserves indentation.
It could also be the case that your original query has improper indentation in the first place.
@Leo_Shestakov are you using the TigerGraph_CLI tool with VSCode to get the GSQL >
terminal?
No, I am just using the standard terminal with the previous command being “gsql”
@rupen you could run this EXPORT GRAPH ALL -T
:
EXPORT GRAPH ALL
The EXPORT GRAPH ALL
command reads the data and metadata for all graphs in the TigerGraph system and writes the information to a zip file in the designated folder. If no options are specified, then a full backup is performed, including schema, data, template information, and user profiles.
Required privilege
EXPORT_GRAPH
Synopsis
The export directory should be empty before running the command because all contents are zipped and compressed.
Parameters
Parameter | Description |
---|---|
directory_name |
The path of the directory to output export files to. Must be an absolute path. |
Options
Option | Description |
---|---|
-S or --SCHEMA |
Only export graph schema. |
-T or --TEMPLATE
|
Only export graph schema, queries, loading jobs and UDFs. |
-D or --DATA
|
Must be used with either -S or -T . Export data in CSV in addition to graph schema or template. |
-U or --Users
|
Must be used with either -S or -T . Export users, role assginments, secrets, and tokens. |
-P or - -Password
|
Encrypt the exported file with a password. Users will be prompted to enter a password when using this option. |
@Leo_Shestakov The original query has the correct indentation as I can see it on “Graph Studio”.
I am using the gsql function for the connection object of the python library pyTigergraph. Python 3.7.0, (pyTigerGraph==0.0.9.8.6).
@Jon_Herke The “export graph all” is creating the exported files on the TigerGraph server, I don’t know if there is a way to access it when it is hosted on TG Could.
@rupen since you’re using pyTigerGraph, please try the following :
conn.gsql("""
USE GRAPH <graphname>
SHOW QUERY <QUERY_NAME>
""")
or
conn.gsql("SHOW QUERY <QUERY_NAME>",graph="<GRAPH_NAME>")
or simply define the graph before gsql command
conn.graphname = "<YOUR_GRAPH>"
conn.gsql("SHOW QUERY <QUERY_NAME>")
these are the three ways you can do using pyTigerGraph, hope that helps
@Mohamed_Zrouga That is exactly what I am doing, but the output is stripped of leading spaces for all lines returned.
graph_name = 'MyGraph'
query_name = 'most_common_mutual_liked_post'
results = conn.gsql(f"""
USE GRAPH {graph_name}
SHOW QUERY {query_name}
""", graphname=graph_name)
print(results)
#### Output
Using graph 'MyGraph'
CREATE QUERY most_common_mutual_liked_post(VERTEX<Post> inPost, INT maxReturn) FOR GRAPH MyGraph SYNTAX v2 {
TYPEDEF tuple<STRING post, INT likes> frequency;
// Find the posts most liked by the group of people who liked the input post
HeapAccum<frequency>(maxReturn, likes DESC) @@topTestResults;
SumAccum<INT> @likes;
post = {inPost};
ml = SELECT op FROM post - (<liked) - Person - (liked>) - Post:op
ACCUM
op.@likes += 1
POST-ACCUM
@@topTestResults += frequency(op.id, op.@likes);
PRINT @@topTestResults;
}
####