1

I am trying to connect my redshift database from AWS Lambda function. I am getting below error when I try to achieve the connection.

Unable to import module 'lambda_function': No module named 'sqlalchemy'

Below is the import code that I am using in my lambda. I have tried all possible import function. Still noting works. Results in the same error.

from __future__ import print_function

import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker

from flask_sqlalchemy import SQLAlchemy

from flask.ext.sqlalchemy import SQLAlchemy as sa

from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String
from sqlalchemy.orm import sessionmaker
1
  • 1
    sqlalchemy is not preinstalled on lambda so you have to include it in your deployment package: See docs Commented Nov 7, 2017 at 13:51

2 Answers 2

4

As 'sqlalchemy' is not a part of AWS SDK you should include it in your deployment package. If you are deploying it as a .zip file then make sure you have included it in the zip

Sign up to request clarification or add additional context in comments.

Comments

0

Put this lib in a Layer and import in your code, maybe this solve your problem. Like Vijayanath Viswanathan saw, build a layer with .zip file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.