简体   繁体   中英

How to run RDS SQL Server select queries in AWS lambda using boto3 RDS client python?

I am going through AWS boto3 rds documentation for running sql select query on table which is present in RDS SQL Server using python in AWS lambda, but I didn't find any info. Don't we have any option to run RDS SQL queries in AWS lambda? Any ideas!

rds_client = boto3.client('rds')

boto3 library provides API to communicate with AWS API. The AWS RDS API includes of

  1. Listing all RDS Instances
  2. Create new RDS Instances
  3. Stop RDS Instances
  4. Modify RDS Instances
  5. etc

For Lambda or any programming language to communicate with database server, we first need to install database driver. Think of it as a middle-man (drivers) that collect instructions of programming language, convert it to database understandable language, then database to process it and return the information to the middle-man, and middle-man translate it to something your programming language can understand. Boto3 does not come with any relational database drivers.

To allow Lambda to work your RDS SQL Server, you have to install Python's SQL Server driver and upload to Lambda. You can either package it as a standalone zip or make it as a Lambda Layer that can be used across by multiple Lambda Functions. The commonly used SQL Server driver for python is pyodbc

Someone on medium.com have make a blogpost about this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM