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

'@' in password #52

Closed
timothyjlaurent opened this issue Jan 7, 2015 · 9 comments
Closed

'@' in password #52

timothyjlaurent opened this issue Jan 7, 2015 · 9 comments
Labels

Comments

@timothyjlaurent
Copy link

I have an '@' symbol in a password. I tried escaping it with '@' but this also didn't work.

@amjith
Copy link
Member

amjith commented Jan 7, 2015

That's most definitely a bug. I wonder how psql handles this.

In the meantime you can try using the command line switches to prompt for the password instead of using the postgres:// style url.

pgcli -h localhost -p 5432 -U amjith -W app_db

Launching that way will prompt for the password.

@amjith amjith added the bug label Jan 7, 2015
@jackmaney
Copy link

Have you tried URL-escaping the @ to %40?

@drocco007
Copy link
Contributor

Have you tried with the latest pgcli? I successfully connected using a role with an '@' character using pgcli 0.16.0 against a 9.4 server:

postgres=# create role atpw LOGIN PASSWORD '@at';
CREATE ROLE
postgres=# create database atdb owner atpw;
CREATE DATABASE
postgres=# \q

$ pgcli postgres://atpw:@at@localhost:5432/atdb
Version: 0.16.0
Chat: https://gitter.im/amjith/pgcli
Mail: https://groups.google.com/forum/#!forum/pgcli
Home: http://pgcli.com
atdb> 

@amjith
Copy link
Member

amjith commented Mar 3, 2015

Previously I was using my own custom built parsing routine for extracting the password and username from the postgres url. I've replaced that routine with urlparse from python stdlib. So this might not be an issue anymore.

Thanks @drocco007 for testing it. I'll close the issue.

@amjith amjith closed this as completed Mar 3, 2015
@catando
Copy link

catando commented Sep 2, 2019

The issue seems to persist/have returned:

pgcli postgres://atpw:@at@localhost:5432/atdb
could not translate host name "at@localhost" to address: nodename nor servname provided, or not known

A workaround is to escape the @s with sed:

pgcli postgres://atpw:"$(echo '@at'|sed -e s/@/\%40/g)"@localhost:5432/atdb

@j-bennet
Copy link
Contributor

j-bennet commented Sep 2, 2019

@catando What is your pip freeze output?

@j-bennet j-bennet reopened this Sep 2, 2019
@przdev
Copy link

przdev commented Aug 22, 2020

@timothyjlaurent

for @ in password you need to encode @ with %40 and quote whole uri
ex: pgcli 'postgresql://postgres:%40postgres@localhost:5432/postgres'
also with arguments use same
ex: pgcli -h localhost -U postgres -W '@postgres' -d postgres
tested it works

@przdev
Copy link

przdev commented Aug 22, 2020

@j-bennet @amjith above solution work, so you can close issue (if need to add it in readme than I'll happy to contribute)

@j-bennet
Copy link
Contributor

@przdev A note in readme would be good, or better yet, in the docs on the pgcli.com website. Here is the link to docs source:

https://github.com/dbcli/pgcli.com/blob/master/content/pages/3.docs.md

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

No branches or pull requests

7 participants