I used to connect to my AWS-RDS instance this way
import MySQLdb
db = MySQLdb.connect(host=os.getenv('RDS_ENDPOINT'),
user=os.getenv('RDS_USER'),
passwd=os.getenv('RDS_PWD'),
db=os.getenv('RDS_DB'))
or with the help of sqlalchemy, but today it seem to refuse to work with the error (2006, 'SSL connection error: SSL_CTX_set_tmp_dh failed')
I tried to update all the python packages (mysqlclient
, sqlalchemy
), reinstall mysqlclient-dev
, manually reinstall OpenSSL v1.1.1a
but still the same error.
[EDIT]
I manage to connect to the same database using the MySQL CLI
mysql --user=$RDS_USER --host=$RDS_ENDPOINT --password=$RDS_PWD $RDS_DB
[SOLUTION]
It seems that this is a driver issue. I tried with mysqlclient
for python 3 and got this error. Next I tried with mysql.connector
as recommanded but I got encoding issues (as stated in the sqlalchemy doc). Finally, I ended with the pymysql
driver which seems to work with sqlalchemy.
Upgrade mysqlclient package fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With