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

南楼画角 提交于 2021-01-29 17:23:02

问题


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')

回答1:


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.



来源:https://stackoverflow.com/questions/65663732/how-to-run-rds-sql-server-select-queries-in-aws-lambda-using-boto3-rds-client-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!