2

I'm running some test code with a MySQL database using SQLAlchemy. I'm unable to connect to the server using the database URL 'mysql://poopoo:peepee@localhost:32913/test', as it refuses me authentication.

When I try to connect to the database using DBeaver, I get an error informing me that "Public key Retrieval is not allowed". This lead me to this post, suggesting I add ?allowPublicKeyRetrieval=true&useSSL=false to the end of the URL. I can confirm that this method works in DBeaver.

However, adding these to the URL, either in a string or with connect_args, a TypeError is raised, informing me that these are invalid keyword arguments for connect.

How do I add these options to my SQLAlchemy connection?

I'm using testcontainers to generate the MySQL test server, but I don't think that's relevant.

2
  • It depends on the mysql driver you use with sqlalchemy, not on sqlalchemy itself. What driver do you use? (And you can search here on SO if you know the driver as most likely this question already has an answer, like stackoverflow.com/questions/56764221/…) Commented Apr 2 at 5:44
  • I was using the mysqlclient driver, but as suggested by another user I switched to pymysql and that inexplicable seemed to work. Commented Apr 3 at 2:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.