Method to Dumpt GSQL Queries From a Server

Is there any way to get a dump of all the GSQL queries from a server? We have several users that are using GraphStudio to create queries but they want a way to sync them to the local file system so they can be checked into github.

Thanks! - Dan

gsql -g <GRAPH_NAME> “show query *”


If you want to download queries while working in GraphStudio, TigerGraph version 3.0 will have some options:

  1. The Write Query page will have a button to download the individual query you are working on.
  2. The Export Solution feature is modified so that the contents are GSQL scripts rather than custom JSON and YAML. After you export, you could unzip the tarball to find all your GSQL queries. More details will be in the upcoming documentation for the Export feature.


A blog to Extract GSQL queries from TigerGraph and migrate them for your Giraffle project:

Navigate down to “Fetching TigerGraph Queries”

----- Pulled From Blog -----
Now that the setup is finished. Let’s get those TigerGraph queries that are on the server into our own machine. To do this, let’s first enter into the GSQL Shell by running the gradle task:

gradle gsqlShell --console=plain

After you connect to the shell. Make sure you specify the Graph from which you want to pull your queries from with the following command.

use graph GRAPHNAME

Replace GRAPHNAME with your Graph

Now, simply run this command.

show query*

This command will print out the queries in the Command Line area. The idea is that we will take the output, put it in a text file and then parse the output and extract each individual query and make a file for it. The problem with this idea is that it may not print out all the queries depending on how many queries you have or how many lines each query is. For example, I have 40 queries, and they add up to 1000 lines. The shell command printed out 39 of the queries, nearly all of them. If there is an better solution, please let me know.

Now then, let’s create a file called queries.txt to put the printed text in. This is the script I used to parse each query and write it to a file:

If you are going to use this script, make sure you remove any partially printed queries from the gsql shell output.

The TXT_PATH should point to the file where the printed text was placed. The QUERY_PATH should point the folder where you want your queries to be. I recommend the db_scripts/query to be the folder where you put all your queries. Here is a reference.

This is my query from GraphStudio:

Here is how it looks after the process.

I added DROP QUERY and INSTALL QUERY so that we can try to directly install the queries from our remote machine in the next article. If you are going to use the script above to parse the queries, please be cautious. Make sure all the queries from your server came intact. If some of the queries did not show up, we must manually make the files for them.
----- Pulled From Blog -----