Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ENV variables for Postgres (or any other database) query #219

Open
xpertmind opened this issue Dec 17, 2024 · 2 comments
Open

Using ENV variables for Postgres (or any other database) query #219

xpertmind opened this issue Dec 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@xpertmind
Copy link

When I'm using Postgres connector as input, the connection env variables are working.

How to use env variables in SQL query?

i.e

select * from {os.getenv('MY_TABLE')} 
where {os.getenv('MY_FIELD')}  = {os.getenv('SOME_VALUE')}  
order by {os.getenv('SORTED_BY')} ; 

Btw. thanks for the tool, it's really great. I created a short Dockerfile to use it as container, can be found here:
README.md

@tgourdel
Copy link
Contributor

tgourdel commented Dec 17, 2024

Hi @xpertmind,

Quick confirmation, you mean the SQL Query text box inside a Postgres component?

If so, haven't tested it but this looks like how it should work. I'll have to look into it :)

@xpertmind
Copy link
Author

Hi @tgourdel,

yes, exactly.

Bildschirmfoto 2024-12-18 um 09 22 18

This is the error message:

Execution failed on sql '
select * from {os.getenv('MY_TABLE')}
order by id;

': syntax error at or near "{"
LINE 2: select * from {os.getenv('MY_TABLE')}
^

@tgourdel tgourdel added the bug Something isn't working label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants