-
Notifications
You must be signed in to change notification settings - Fork 418
asyncpg does not work with "sslmode" query param when called from SQLAlchemy #737
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
Comments
I think we do use asyncpg/asyncpg/connect_utils.py Lines 308 to 311 in 075114c
Is it the |
This is a bug in SQLAlchemy's |
I wouldn't say it's a bug. Seems more an oversight from SQLAlchemy that this param had to be translated for Line 1747 in 075114c
I'll open an issue on SQLAlchemy to see if they have something to say about that. |
Just find out that there was a similar issue with Is there any chance |
It is weird for SQLAlchemy to require that, given that it's supposed to be an abstraction over varying driver implementations. The |
Oh... Now I got it. Seems a simple fix on the SQLAlchemy side. I opened an issue there: sqlalchemy/sqlalchemy#6275 |
@igortg have you been able to make it work? I read linked issue but I can't make engine creator working with async connect function and also an option with make_url still throws the same error about sslmode parameter.
I can't get it |
On asyncpg the query string is |
Hm, with this setup I receive the following error:
If I change
I receive another one:
So I'm not sure that ssl parameter was passed ok to DigitalOcean eventually (but maybe it is). Also I have |
I am not sure why it still does not work after this #768 ? |
Hello, after running into this problem as well, I think it is a conflict of documentation versus how Postgresql annotates SSL Support (https://www.postgresql.org/docs/9.1/libpq-ssl.html) The code accepts a But the problem I think is the assumption that the keyword It is still not clear to me when to choose between |
After using
Do you know any solution so I can still use |
Here's how I finally got it to work (sqlalchemy/sqlalchemy#5975): from ssl import create_default_context, Purpose as SSLPurpose
ssl_context = create_default_context(
SSLPurpose.CLIENT_AUTH,
cafile="docker-compose.d/cockroach-certs/ca.crt"
)
ssl_context.load_cert_chain(
"docker-compose.d/cockroach-certs/client.root.crt",
keyfile="docker-compose.d/cockroach-certs/client.root.key"
)
ssl_context.check_hostname = True
_engine = create_async_engine(
"cockroachdb+asyncpg://root@localhost:26257/mydb",
echo=True,
connect_args={"ssl": ssl_context}
) Equivalent to |
Another solution is here: https://github.com/cossacklabs/acra/blob/e8ca8203dfe92566762cb1638667a62c204e4263/tests/test.py#L228 |
See MagicStack/asyncpg#737 for background
this worked for me, thanks! |
@evindunn What if my sslrootcert is a string and not a file? |
the issue with a local PostgreSQL install?: I use DigitalOcean and was able to also reproduce it locally
uvloop?: N/D
First, congratulation to the people of MagicStack for this great library.
When using DigitalOcean default environment DATABASE URL to set the database string on my app I got the following error:
In my app, since I use
psycopg2
to do some "management tasks", I also need to do something like that:Shouldn't
asyncpg
use the more standardsslmode=
query param instead of thessl=
?The text was updated successfully, but these errors were encountered: