1

I've been using ipython notebook and there are 2 information (SNOW_USER and PASSWORD) that I need to pass so I can connect to the database. I don't want to expose it for security reasons.

I tried to set as ENV VAR (environmental variables) saving it on my .bash_profile and also on .profile using export SNOW_USER='abc' but it doesn't seem ipython can find it.

import os
print os.environ['SNOW_USER']

I also tried:

%env

But the variables are not showing there either.

Any thoughts on how to do it?

7
  • Did you logout and in after? Or source ~/.bash_profile Commented Apr 6, 2016 at 20:08
  • @PadraicCunningham Yes. I shutdown the notebook and open it afterwards. Commented Apr 6, 2016 at 20:09
  • Hmm, that should work. Commented Apr 6, 2016 at 20:11
  • Try logout. If you open the notebook from your window manager but it hasn't been restarted, you are still using the old environment. Commented Apr 6, 2016 at 20:15
  • @tdelaney, they have logged out and back in so that should not be the issue no? Commented Apr 6, 2016 at 20:15

1 Answer 1

1

Try to create a file .env somewhere with in it :

export SNOW_USER="snow_user"
export PASSWORD="password"

and then source it :

source .env

Or just source you bash_profile file :

source ~/.bash_profile
Sign up to request clarification or add additional context in comments.

9 Comments

@PadraicCunningham I haven't tried creating .env. It worked out. I'm not sure why the bash_profile didn't work.
@lizzie, I thought you added to ~/.bash_profille as per your question and comment?
@PadraicCunningham I did add to my bash_profile. What I didn't have was the .env file.
@lizzie the .env or the bash_profile work the same. You just have to source it somehow. But usually it is good to have a .env at the root of your project.
@Till Great to know!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.