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

0.36.8 breaks database_exists() call #462

Closed
pmezard opened this issue Jul 9, 2020 · 6 comments · Fixed by #506 · May be fixed by #463
Closed

0.36.8 breaks database_exists() call #462

pmezard opened this issue Jul 9, 2020 · 6 comments · Fixed by #506 · May be fixed by #463

Comments

@pmezard
Copy link

pmezard commented Jul 9, 2020

Hello,

We have code doing something like:

url = "postgresql+psycopg2://user:password@localhost/db"
if not sqlalchemy_utils.database_exists(url):
    ....

It works with 0.36.7 but fails with 0.36.8 with:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL:  database "user" does not exist

I think the new code attempts to connect to "user" default database, which is "user". Unfortunately, this database does not exist.

Is this a bug, or should we modify our code in any way?

Thanks.

@oxlade39
Copy link

+1 on this. Seeing the exact same issue after upgrading

@PJEstrada
Copy link

+1 Have the same issue too.

@jtbeach
Copy link

jtbeach commented Jul 15, 2020

Can we have a parameter to database_exists to control which database to connect to in order to perform the check?

@k4r1
Copy link

k4r1 commented Jul 15, 2020

This code has been changed recently, originally it connected to template1 to perform the existence check, that was then changed to postgres, and finally this PR removed that logic entirely and instead sets database to none.

I think @jtbeach's suggestion makes sense, due to it being difficult to find a database that is guaranteed to exist (and to which connections are allowed) in every single case.

@k4r1
Copy link

k4r1 commented Jul 15, 2020

Looks like there's a fix with the suggested behaviour already in a PR: #463

@jtbeach
Copy link

jtbeach commented Jul 15, 2020

Looks like there's a fix with the suggested behaviour already in a PR: #463

There's a couple of bugs in that PR -- have put a couple of comments on there

nsoranzo added a commit to nsoranzo/galaxy that referenced this issue Nov 9, 2020
nsoranzo added a commit to nsoranzo/galaxy that referenced this issue Nov 9, 2020
nsoranzo added a commit to nsoranzo/galaxy that referenced this issue Nov 14, 2020
nsoranzo added a commit to nsoranzo/galaxy that referenced this issue Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants