Retrieve logs from SQL query in Airflow #764
Unanswered
thegunner157
asked this question in
Questions
Replies: 1 comment 1 reply
-
Hi, what's the relation between this question and SQLModel? This is a place to ask (and answer) questions about SQLModel. Seems like your question is related to airflow... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Hi guys,
I want to retrieve logs from executed SQL stored procedure. Procedure does not return anything, but I want to get logs from it.
I tried to use SQLExecuteQueryOperator which calls SQL command and in post_execute function I tried to use TaskLogReader object and call read_log_chunks function with passed proper task_instance, try_number and metadata either as None or {end_of_log: True}.
However I constantly get error that I couldn’t read served logs and then below I get DetachedInstanceError from sqlalchemy which says “Parent instance is not bound to Session; lazy load operation “trigger” cannot proceed.”
Now the question is, can I somehow in post_execute function change task state to deferred or change the sql session from task instance level to enable logs? Or is there any solution that I can retrieve those logs from SQL?
I’m using Airflow in version 2.7.1.
Thanks guys in advance!
Operating System
Windows
Operating System Details
No response
SQLModel Version
I use qlalchemy
Python Version
3.9
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions