Reputation: 177
I am relatively new to airflow and I keep hitting warnings that say
DeprecationWarning: Importing 'MsSqlHook' directly from 'airflow.hooks' has been deprecated. Please import from 'airflow.hooks.[operator_module]' instead. Support for direct imports will be dropped entirely in Airflow 2.0.
Can someone tell me what I am doing wrong here and what will be changed? I typically write my database login into PythonOperator functions using hooks to connect to the DB. Is this no longer allowed in 2.0? I am missing some contextual information it seems.
Upvotes: 1
Views: 1852
Reputation: 11607
What version of Airflow are you using? (answer might change based on that)
Here's what i think
You are importing the hook from __ini__.py
of hooks
package, which is deprecated.
Instead change your import statement to from airflow.hooks.mssql_hook import MsSqlHook
, so that you are importing it from mssql_hook.py
module instead
Do note that
from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook
Upvotes: 2