import sys
import logging
import rds_config
import pymysql
#rds settings
rds_host = "xxxxxx"
name = rds_config.db_username
password = rds_config.db_password
db_name = rds_config.db_name
logger = logging.getLogger()
logger.setLevel(logging.INFO)
try:
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
except:
logger.error("ERROR: Unexpected error: Could not connect to MySQL instance.")
sys.exit()
logger.info("SUCCESS: Connection to RDS MySQL instance succeeded")
def handler(event, context):
"""
This function fetches content from MySQL RDS instance
"""
data = ''
with conn.cursor() as cur:
cur.execute("Select * from xxxxx where Status = 'Active';")
for row in cur:
logger.info(row)
data+= " ".join(map(str, row)) + "\n"
return data
Я получаю ответ, как показано ниже
Response:
"1 xxxxxxx Full Active 2019-12-31\n2 yyyyyyyy Full Active 2019-12-31\n"
Я хочу получить его, как показано ниже (без кавычек?)
Response:
"1 xxxxxxx Full Active 2019-12-31"
"2 yyyyyyyy Full Active 2019-12-31"
Новичок Python.Может ли кто-нибудь помочь, пожалуйста?