To fix this issue with SQLAlchemy, you need to use the correct driver syntax. For MySQL connections with public key retrieval, use mysql+pymysql://
instead of mysql://
and add the parameters to the query string:
engine = create_engine('mysql+pymysql://poopoo:peepee@localhost:32913/test?allowPublicKeyRetrieval=true&useSSL=false')
If you're still getting errors, you can also try passing these parameters via connect_args
with the correct format:
engine = create_engine(
'mysql+pymysql://poopoo:peepee@localhost:32913/test',
connect_args={
"ssl": {"ssl_mode": "DISABLED"},
"allow_public_key_retrieval": True
}
)
Make sure you have the pymysql driver installed: pip install pymysql
.