Skip to main content

Hello,

I am trying to set up a database extractor for SQL Server database. I would like to pass parameters to the query so that the extraction logic can be controlled via the env file. 

Here is what I have done.

  1. Created an environment variable called “DEPT_ID”,
  2. In the YAML file, I am using ${DEPT_ID} to use the value of the env variable. 

 

SELECT
*
FROM
bEmployee]
WHERE >Dept_id] = ${DEPT_ID}

 

While running the DB-Extractor, I am encountering the following error.

KeyError: DEPT_ID

 

I am wondering if the product even supports the use of parameterized queries in the DB-Extractor.

Any help will be greatly appreciated. 

 

Thanks,

Dinesh

Hi @dinesh.makked 

We have forwarded your request to our engineering team and will share an update with you soon.

Thank you
Isha


Using environment variables in this way should work, see here: https://docs.cognite.com/cdf/integration/guides/extraction/configuration/db#using-values-from-environment-variables.

However, the  Key Error: DEPT_ID indicates that the environment variable DEPT_ID is not defined. 

Are you running the DB extractor through Docker? If so, remember that you need to pass over any environment variables to the docker container for them to be available, see here: https://docs.cognite.com/pt/cdf/integration/guides/extraction/db/db_setup/#step-2-run-the-docker-container
 

Hope that this helps. Keep extracting!

 


Reply