Below is the command to generate models from database directly in quick fashion.

$ pip install sqlacodegen

$ pip install pymysql

Create your db schema.

now issue the following command

$ sqlacodegen mysql+pymysql://Nich:Bossdk#@localhost/dev

the output will be like given below

class User(Base):
__tablename__ = ‘user’

user_id = Column(Integer, primary_key=True)
first_name = Column(String(255), nullable=False)
last_name = Column(String(255))
email_id = Column(String(255), unique=True)
phone_no = Column(BigInteger)
country = Column(String(50))
_pass = Column(‘pass’, String(255))



Run the following commands

npm install -g serverless

serverless config credentials --provider aws --key XXXXXXXXXEXAMPLE --secret XXXXXXXXX/XXXXXXX/XXXXXXXXX

Also make sure the IAM user for which we would be using aws key and secret should have following policies attached

serverless create — template aws-nodejs — path hello-world-medium

cd hello-world-medium

serverless deploy -v



I created the lambda function to generate access token and id token as mentioned in my previous blogs.The access token we decoded will show something like.

“sub”: “5ccc31a1–4934–455f-8d83–1ec4b49b1df2”,
“cognito:groups”: [
“event_id”: “e4308419–92da-49e5–961a-b3df624e3c40”,
“token_use”: “access”,
“scope”: “aws.cognito.signin.user.admin”,
“auth_time”: 1610342817,
“iss”: “",
“exp”: 1610346417,
“iat”: 1610342817,
“jti”: “83abd9c1–1a08–41af-bc37-d6d64a68d7e6”,