I'm having a hard time trying to connect to my s3 bucket to read the xml file with lambda I'm using "xml.estree.ElementTree". Then I want to be able to upload them into tables in oracle.
Example: file.xml
<row>
<Id >1234</Id>
<Name>Jon</Name>
</row>
<row>
<Id>1244</Id>
<Name>Doe</Name>
</row>
import json
from xml.dom import minidom
import boto3
s3 = boto3.resource('s3')
def lambda_handler(event, context):
bucketname = 'my bucket'
filename = 'file.xml'
obj = s3.Object(bucketname, filename)
file_data = obj.get()['Body'].read()
#parse xml
xmldoc = minidom.parseString(file_data)
rows = xmldoc.getElementsByTagName("row")
for row in rows:
Id = row.getElementsByTagName("Id")[0]
Name = row.getElementsByTagName("Name")[0]
print("Id:% s, Name:% s"
(Id.firstChild.data, Name.firstChild.data))
This is the current code I have that reads it how can I upload it to a oracle database table.
Any help or guidance will be appreciated.