最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

trying to use MysqlOperator and PostgresOperator of Airflow - Stack Overflow

programmeradmin5浏览0评论

I am trying to use MysqlOperator and PostgresOperator of Airflow

from airflow.operators.postgres_operator import PostgresOperator
from airflow.providers.mysql.operators.mysql import MySqlOperator

Even though I installed all the required files, I still get the same error:

ModuleNotFoundError: No module named 'airflow.providers.postgres.operators'

I am trying to use MysqlOperator and PostgresOperator of Airflow

from airflow.operators.postgres_operator import PostgresOperator
from airflow.providers.mysql.operators.mysql import MySqlOperator

Even though I installed all the required files, I still get the same error:

ModuleNotFoundError: No module named 'airflow.providers.postgres.operators'

Share Improve this question asked Mar 21 at 22:53 AleynaAleyna 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The individual Operators for databases have been replaced with the Sql Commons operators. Specifically, if you are running those two, you will want to use the SQLExecuteQueryOperator. If you look at the operator, it pulls the appropriate hook based on the connection type specified in the conn_id.

If you would still like to use the PostgresOperator, you can call it in Postgres providers versions up to 5.14.0 and 5.7.4 for the MySqlOperator, but you'll notice looking at the actual code itself that it will essentially redirect you to the SqlExecuteQueryOperator and provide a deprecation warning.

You still need to install the Providers packages to get the proper hook for the connection, but for your dag code itself, you only need one import.

from airflow.providersmon.sql.operators.sql import SQLExecuteQueryOperator

发布评论

评论列表(0)

  1. 暂无评论