Just connect from your Python code (like the lambda in the example) to DB and extract the necessary data.