[ https://issues.apache.org/jira/browse/AIRFLOW-3618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ryan Griffin closed AIRFLOW-3618. --------------------------------- Resolution: Not A Problem The issue was that I was adding the connections through the CLI: {code:java} airflow connections --add --conn_id test_local_mysql --conn_type "MySQL" ...{code} This was done to match the name of the connection in the UI. Once the *--conn_type* was updated to be "mysql", it worked as expected. > airflow.models.connection.Connection class function get_hook doesn't work > ------------------------------------------------------------------------- > > Key: AIRFLOW-3618 > URL: https://issues.apache.org/jira/browse/AIRFLOW-3618 > Project: Apache Airflow > Issue Type: Bug > Components: models > Affects Versions: 1.10.1 > Environment: MacOS, iTerm, python 3.5.2 > Reporter: Ryan Griffin > Priority: Major > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > The airflow.models.connection.Connection class function get_hook does not > work as expected. > It is currently using self.conn_type == 'type', where the 'type' is always > lowercase. In practice this is not true, and causes the get_hook function to > always return a NoneType. > Here is an example: > {code:java} > >>> import airflow > >>> from airflow.hooks.base_hook import BaseHook > >>> airflow.__version__ > '1.10.1' > >>> conn = BaseHook.get_connection('test_local_mysql') > [2019-01-02 11:36:15,530] {base_hook.py:83} INFO - Using connection to: > localhost > >>> conn.conn_type > 'MySQL' > >>> type(conn.get_hook()) > <class 'NoneType'> > >>> conn.conn_type = conn.conn_type.lower() > >>> conn.conn_type > 'mysql' > >>> type(conn.get_hook()) > <class 'airflow.hooks.mysql_hook.MySqlHook'>{code} > > As you can see, when using the BaseHook class to get the connection, the > conn_type is *MySQL* instead of *mysql*, so it is unable to find the correct > type to get the hook (reference: > [https://github.com/apache/incubator-airflow/blob/master/airflow/models/connection.py#L178).] > By forcing the conn_type to be lowercase, the *get_hook* function now works. -- This message was sent by Atlassian JIRA (v7.6.3#76005)