title: Read JSON from S3 and upload it to RDS using Lambda through
body: <p>I am trying to read JSON from S3 and upload it to RDS using Lambda. The code in Lambda is as follows:</p>
  <pre><code>import json
  import boto3
  import pymysql
  s3_client = boto3.client('s3')
  def lambda_handler(event, context):
      bucket = event['Records']['0']['s3']['bucket']['name']
      json_file_name = event['Records'][0]['s3']['object']['key']
      json_object = s3_client.get_object(Bucket=bucket,Key=json_file_name)
      jsonFileReader = json_object['Body'].read()
      jsonDict = json.loads(jsonFileReader)
      results = []
      for item in (jsonDict):
           results.append(row.values())
      print(results)
      conn = pymysql.connect(host = 'rchd.cypgvdgyrj6p.us-east-1.rds.amazonaws.com',user = 'rchd',passwd = 'rchdrchd',db = 'rchd')
      cursor = conn.cursor()
      pymysql_insert = cursor.execute(&quot;INSERT INTO rchd2(uniquedataid, platformdetails, systemname, processorname, architecturaldetail, nodename) VALUES (%s, %s, %s, %s, %s, %s)&quot;
      cursor.execute(pymysql_insert,results)
      conn.commit()
      cursor.close()
      conn.close()
      print(cursor.rowcount, &quot;record inserted successfully into employee table&quot;)
      return {
          'statusCode' : 200,
          #'body' json.dumps('hello from lambda!')
         
      }
  </code></pre>
  <p>However, Lambda is giving the following error in <code>Line 18</code>:</p>
  <pre><code>Response
  {
    &quot;errorMessage&quot;: &quot;Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 18)&quot;,
    &quot;errorType&quot;: &quot;Runtime.UserCodeSyntaxError&quot;,
    &quot;requestId&quot;: &quot;52039e38-4d6a-4a6f-a29f-b47ae91c7f37&quot;,
    &quot;stackTrace&quot;: [
      &quot;  File \&quot;/var/task/lambda_function.py\&quot; Line 18\n        cursor.execute(pymysql_insert,results)\n&quot;
    ]
  }
  
  Function Logs
  START RequestId: 52039e38-4d6a-4a6f-a29f-b47ae91c7f37 Version: $LATEST
  [ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 18)
  Traceback (most recent call last):
    File &quot;/var/task/lambda_function.py&quot; Line 18
          cursor.execute(pymysql_insert,results)END RequestId: 52039e38-4d6a-4a6f-a29f-b47ae91c7f37
  </code></pre>
  <p>Based on the error i think its in my SQL insertion command. I tried many times to fix it. But unable to do so.</p>
  <p>Can anyone let me know how to correct it?</p>
  <p>Any help would be appreciated.</p>