I am trying to do local development setup for serverless architecture. Amazon provide SAM Local Beta for doing so. But in my project we are using mysql database. I am trying to make a connection to my local mysql server it failed saying.
module initialization error:
(2003, "Can't connect to MySQL server on 'localhost'
([Errno 99] Cannot assign requested address)")
Below is my python code:
import json
import pymysql
def lambda_sandbox_down_handler(event, context):
rds_host = 'localhost'
name = 'localhost'
password = 'localhost'
db_name = 'localhost'
conn = pymysql.connect(rds_host,port=3306, user=name, passwd=password,
db=db_name,charset='utf8mb4',connect_timeout=5)
return conn
I am able to make connection using command line as well as pycharm.
My question is this possible in SAM local.
I have installed a docker image of mysql and started it. After this I am still getting the same error.