★ wanayoo — archive 1999 https://github.com/catherinedevlin/ipython-sql/pull/94Nouvelle recherche | Portail wanayoo
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

call __repr__() on url rather than __str__() to hide password #94

Open
wants to merge 2 commits into
base: master
from

Conversation

@jstoebel
Copy link
Collaborator

jstoebel commented Jul 30, 2017 •

calling __repr__() rather than __str__() on the connection url object hides the password.
this should close #91

@jstoebel jstoebel force-pushed the jstoebel:iss91 branch from 2c240f4 to 111cede Jul 30, 2017
@jstoebel
Copy link
Collaborator Author

jstoebel commented Jul 30, 2017

Since sqlite does not use a password in the connection string we can't test this under the current set up AFAIK. is there an interest in setting up a testing environment with CircleCI or something similar so we can easily run tests against postgres?

@jstoebel jstoebel changed the title assemble connection string from url attributes call __repr__() on url rather than __str__() to hide password Jul 30, 2017
@jstoebel
Copy link
Collaborator Author

jstoebel commented Jul 31, 2017

also: for some reason the connection string is sometimes printed out more than once. I am looking into this.

@jstoebel
Copy link
Collaborator Author

jstoebel commented Jul 31, 2017 •

it looks like the culprit is in sql.connection.Connection.__init__ , specifically:

        self.connections[self.name] = self
        self.connections[str(self.metadata.bind.url)] = self

Here it looks like we are mapping the connection's assigned name and its url to the the Connection instance. Do we want to maintain both representations of the connection in the connections dictionary? More to the point, do we want to print out both? Being new to this library I'm not sure

@catherinedevlin
Copy link
Owner

catherinedevlin commented Jul 31, 2017

Ah, I semi-remember now: the idea was that you'd be able to refer to a connection either by its full connection string, or by an abbreviated version. That way you could use %sql (connection) to switch back to an earlier connection without giving the full connection string. So, like this (this is on the current master branch):

`In [5]: %sql postgresql://passwordy:password@/catherine
Out[5]: 'Connected: passwordy@catherine'

In [6]: %sql sqlite:///mydb.sqlite
Out[6]: 'Connected: @mydb.sqlite'

In [7]: %sql

  • @mydb.sqlite
    passwordy@catherine
    postgresql://passwordy:password@/catherine
  • sqlite:///mydb.sqlite
    Out[7]: 'Connected: @mydb.sqlite'

In [8]: %sql passwordy@catherine
Out[8]: 'Connected: passwordy@catherine'`

Can we maintain that capability?

@jstoebel
Copy link
Collaborator Author

jstoebel commented Jul 31, 2017

gotcha, so I guess we're good with that

calling it during connection_list causes the shortened connection name (like user@mydb) to not be displayed
@jstoebel
Copy link
Collaborator Author

jstoebel commented Jul 31, 2017

do you have any thoughts on how to test for this fix? (see above)

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

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.