1 Answer
- Newest
- Most votes
- Most comments
1
You did not include your code here, but could it be that you are running your query outside the handler code? If you do, you should note that yje code outside the handler is invoked only once during the initialization stage of your execution environment.n If this is the case, move your query inside the handler and run it for each invocation.
Relevant content
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
Thank you Uri Perfect. Yes - you're absolutely correct. I was connecting to the DB outside of the event handler, even though the query was inside the event handler. I've moved the connect inside and it's working now. I apologise - I think I did read this in the help, but clearly it didn't "go in".
Actually, creating the connection outside the handler is recommend best practice usually. I think in your case there is something cached on the connection object itself. You can create the connection for every request, or maybe there is some mechanism on the connection itself to refresh it.