You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/19 05:44:41 UTC
[GitHub] [airflow] MatrixManAtYrService commented on pull request #15581: Add optional result handler to database hooks
MatrixManAtYrService commented on pull request #15581:
URL: https://github.com/apache/airflow/pull/15581#issuecomment-843763802
I got this working, it looked like this:
```python3
def handler(cur):
hello, world = cur.fetchone()
message = f"{hello} {world}!"
return message
@task
def mytask():
hook = SqliteHook(sqlite_conn_id="my_conn_id")
message = hook.run(my_sql, handler=handler)
print(message)
```
As it stands, I don't think this works:
```python3
SqliteOperator(
task_id="some_id",
sql=my_sql,
sqlite_conn_id="sqlite_conn_id",
handler=handler #<--- no such kwarg
)
```
Do we want to add the handler kwarg to the operators too? Not that the return value would be helpful there, but users could call `get_current_context` in the handler and push the outputs to xcom or something like that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org