I added a few, I'm not sure if any more would be useful. Also, is this all I have to do to write a lambda? I was given very little instruction on how to do it. It returns the result from the query like it's supposed to. I don't see anything wrong with it except for adding some logging exceptions?
import logging
import os
import sys
import mariadb as mdb
cnxn = mdb.connect(
user="username",
password="pass",
host="host",
port=port,
database="database"
)
cur=cnxn.cursor()
SQL_QUERY="CALL STORED_PROCEDURE();"
cur.execute(SQL_QUERY)
row=cur.fetchone()
def name_of_handler(event=None, context=None):
try:
cur.execute(SQL_QUERY)
cnxn.commit()
except mdb.Error as e:
print(f"Error: {e}")
except Exception as e:
logging.exception(e)
print(row)
cnxn.close()
name_of_handler()
UPDATE: Nevermind, how do I write a message saying "executed successfully?" I see the records did insert into the database, but there is no confirmation in the python code.