How to Query RDS MySQL From AWS Lambda in Python | Step by Step Tutorial

preview_player
Показать описание
Trying to connect to RDS from a Lambda function but having Trouble? This is the video for you.

02:11 Installing Pymysql
03:00 Writing our Lambda Handler Function with Python
07:45 Preparing your handler and dependencies for Lambda
08:26 Creating our Lambda Function
10:43 Testing our Function

🎉 SUPPORT BE A BETTER DEV 🎉

📚 MY RECOMMENDED READING LIST FOR SOFTWARE DEVELOPERS📚

🎙 MY RECORDING EQUIPMENT 🎙

💻 MY DESKTOP EQUIPMENT 💻

📚 References:

☁Topics covered include:
RDS MySQL Connection
Lambda RDS IAM Permissions
Pymysql for Querying RDS MySQL

🌎 Find me here:

#AWS
#Serverless
#RDS
#MySQL
Рекомендации по теме
Комментарии
Автор

If anyone is getting an error saying "__init__() takes 1 positional argument but 2 positional arguments (and 3 keyword-only arguments) were given" I was able to fix it by looking at the pymysql docs, you need to add host=endpoint to your connect parameters like so:

connection = pymysql.connect(host=endpoint, user=username, password=password, db=database_name)

timmoran
Автор

Your videos on this have been pivotal in my most recent project. Thank you for these!!! Will be giving credit in my vid!

KenJee_ds
Автор

This is by far the best explanation I've seen for setting this up. This really broke a logjam for me. Thank you.

GonnaBeALongWalkHome
Автор

That was a great video. Thanks for the help.

As a note, I had to add the VPC details of the RDS instance to the Lambda Function. This allowed accessing RDS in a secure VPC network.

MrSydadder
Автор

Thank you very much for this tutorial. Very detailed and no questions in return. It worked for me in the single go! Cheers! 🙂

YashwanthAluru
Автор

Oh, I've been searching for this one. THANKS!!

jumboliah
Автор

5:00 Hi, thanks for the great video. On my vscode, my code isn't colour-labelled as on Daniel's. What am I missing for installation?

rustylobster
Автор

This is an awesome Tutorial .. Short and Simple. Very Nicely explained.. Keep making these kind of videos .. Its gonna help lots of People to learn AWS without going through the lengthy tutorials we see these days.. Liked and Subscribed .. :)

akashnarvekar
Автор

Thanks a lot for this type of content!!


I'm familiar with SQL, Python, and to some extent Lambdas all individually, but putting them all cohesively together to implement a workflow like this is something that would've taken me ages on my own. Thanks a tonne for illuminating most of the path forward!!


Just a follow up question though - what's one example of a use-case for this kind of SQL querying from a lambda trigger? I'm curious about various ways you could use the output of that query to do something useful, but not that much comes to mind currently. I'm sure I'm missing a lot!

theteacher
Автор

Hello! I'm wondering why we need the VPC policy when we connect via an enpoint which is pretty much public? Thank you! Sorry for noob-ish question.

JordanCote
Автор

Thank you so much for this Tutorial and the previous one before it. I was fumbling around with many other tutorials before I found this and it was spot on! I'm subscribed and will be checking out your other videos as I'm sure there's a lot I can learn from this channel!

OnceIcaughtafiash
Автор

‼‼Question: Do I need to connect to database for each of my lambda in this way, like each of my lambda will have separate connection to database. OR is there any general connection to database at once which I can use across all the lambdas?
Remember I'm not talking about databse connection code which we can reuse across all the lambdas rather about database singleton kind of instance which could be use across all lambdas. Thanks

muzammalabdulghafoor
Автор

Hi, Very useful. how do I make it more user interactable like creating a form or a page where user input a value and retrieves some data out and display it.

eswarr
Автор

hello, thank you for the video, how do you do if you want to setup an api and a json formatted return ?

georgia-pro
Автор

Hi Can you explain how to connect Private RDS using Lambda?

MdNababuddin
Автор

Bro, is there a way where we can query rds directly without using lambda and send notifications to email ? Currently I don’t want to use lambda i have an rds and cloudwatch and using that i need to get a notification with there is any status with error in one of the database in rds

nikhilkachhela
Автор

Thank you for the vid, the only problem I faced is that I had to specify which vpc the lambda should be in because in my case my RDS was inside a vpc.

yeaboi
Автор

So each lambda will have its own db connection object ? Is it there any benefit with common util function that can provide connection object to these lambda?

satyak
Автор

This is great and really well explained. Thanks!

tpol
Автор

Hey this is great place to begin with AWS db and lambda, Could you also make a similar play through video on using database proxy, environment variables and other best practices for production? Would love to understand the best practices you follow in prod.

AbhayNayak
visit shbcf.ru