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

secure database credentials #36

Open
christophlingg opened this issue Jun 4, 2015 · 7 comments
Open

secure database credentials #36

christophlingg opened this issue Jun 4, 2015 · 7 comments

Comments

@christophlingg
Copy link

Hello!

we are sharing our notebooks on github and want to avoid commiting our db credentials. Therefore we want to use environment variables. Is there any chance to do so:

%sql postgresql://db_user:db_passwd@localhost:db_port/dbname

normally you can use :variable to read variables, but this case is special

@AndreaCrotti
Copy link

+1 on this @christophlingg

What do you mean by using :variable anyway?
I think it's an issue with the Ipython magic things more in general, is that correct?

@christophlingg
Copy link
Author

@AndreaCrotti on the readme you can find an example for :variable

In [12]: name = 'Countess'
In [13]: %sql select description from character where charname = :name

@AndreaCrotti
Copy link

Ah ok I see..
Anyway I think the file that needs some changes for this to work is:

https://github.com/catherinedevlin/ipython-sql/blob/master/src/sql/magic.py

I was trying now to do some debugging but trying to put an ipdb there doesn't seem to work, it should not be too hard though..

@invisiblefunnel
Copy link

I was wondering the same thing and found this related post. Here's how to pass database creds from an environment variable:

%load_ext sql
from os import environ
 db_url = environ['DATABASE_URL']
%sql $db_url

@mottalrd
Copy link

mottalrd commented Oct 8, 2015

I was browsing for the same, @invisiblefunnel solution is what I was looking for.
adding a note to the README would be great.

@eshilts
Copy link
Contributor

eshilts commented Feb 23, 2016

I ran into this same issue. Thanks, @invisiblefunnel for the solution. I submitted a PR with that solution in the README.
#52

@tosolveit
Copy link

This is a great feature, I see that it has been merged but I think we don't get it with pip install, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants