Get the current working directory from query?

Is there an easy way to get the current working directory inside a query?

I would like to create log files from a query like below:

FILE logfile (PWD + “test.log”)

My understanding is that there is no relevant functionality.
Anyhow, it would not make sense to refer to current working directory in most of the cases as it simply would not exist: when you connect to the database via GraphStudio or REST API, there is no any current/relative path. That only exists in some form if you start gsql command line on the database server. But what if it’s a remote gsql connection? Database can’t write file to your laptop’s disk.

Thanks @SzilardTG!

Your explanation makes sense. The reason I am asking about this is that if I create a file handle with just the file name like below I have no idea where that file is saved.

FILE logfile(“test.log”)

My current workaround is to provide an absolute path when declaring a FILE. This will certainly break in the scenarios that you listed above where having current working directory would not make sense.

Documentation states that “Currently, the filePath must be an absolute path.”, so your approach is the correct one (as long as the absolute path you provide is on the database server).

If you do not specify absolute path, the file would be created in /home/tigergraph/tigergraph/app/3.0.0/bin (or something similar, depending on your setup), which is not a good thing considering that bin is reserved for system components.

Perhaps the best solution would be an app that uses the REST API (perhaps via pyTigerGraph) that pulls results (from queries) and writes it to a location that is selected by the end user.


Talking about pyTigerGraph, are TigerGraph users generally using pyTigerGraph or writing GSQL queries directly?


I do no think we can say which one is more used; there are use cases for both. And both can and – in most of the cases – should be used at the same time.

  • The heavy weight analytics should be developed as GSQL queries and run in the graph/in the database. This includes some ML/DL/AI work, like neural networks and feature extraction.
  • Integration between TigerGraph and Python ML/DL/AI libraries and frameworks can/should be done using pyTigerGraph, which is effectively just a connector between TG and Python.

pyTigerGraph at this stage is stronger in supporting data science activities, but we are working on expanding the data engineering functionality too.

1 Like

Ok. I just got started on this and will explore what works the best for my use cases. Thanks!