Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to read Memgraph process environment variables from a query module?

I’m developing a query module. I need to use some environment variables. I want to configure the module without hardcoding values inside the module. What can I do? I’d like to avoid reading values from external text files.

Is there a way to access Memgraph ENV variables?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In Memmgraph query modules have access to the Memgraph’s environment variables. Here is the code that you can use for testing:

import mgp
  
import os
  
home = os.getenv("HOME")
my_env = os.getenv("MY_ENV_VAR")
  
@mgp.read_proc
def procedure() -> mgp.Record():
    print(my_env)
    print(home)
    return mgp.Record()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading