Does SQLAlchemy in AWS Lambda?

193 views
Skip to first unread message

Mike Soultanian

unread,
Jul 5, 2020, 12:32:45 PM7/5/20
to sqlalchemy
Is anyone successfully using SQLAlchemy in Lambda?  I'm having the hardest time trying to get it to work - first it times out when I try and connect using mysql+mysqldb, so then I downloaded the package and created a layer (pip3 install mysqlclient -t folder) and packaged that up and added it as a layer and now it's generating "name '_mysql' is not defined" - I've also tried using pymysql without success (I think I was getting a key error 255 because it doesn't support mysql 8, but that github message was from 2017).

So, instead of me posting everything I've tried, I figured I'd first see if anyone has even gotten it to work.  If so, I'd love to know how you did it... otherwise I'm debating just setting up an EC2 instance instead as I know it works that way...

Thanks!
Mike

Mike Soultanian

unread,
Jul 5, 2020, 4:28:57 PM7/5/20
to sqlalchemy
Wow - after spending another three hours and trying to get tutorials to work (without SQLAlchemy), I finally got it figured out.  It looks like I didn't have my security group inbound/outbound rules set up correctly - wow.... that was a major pain!  I guess that's how it goes when you're learning something new!

Btw, if I'm using SQLAlchemy with Lambda, do I still need to be careful of concurrent DB sessions and use scoped_sessions?  I watched something about the fact that with Lambda a container is created and the pool gets left open (or something like that), so I figured it would be worth asking.  It's easy enough to use either way to be on the safe side.  I think there was also something about using an RDS proxy as well - I'll have to look into that, too.

Thanks!
Mike
Reply all
Reply to author
Forward
0 new messages