Reputation: 145
I need to poll DB2 database table until a record is created and once it is successful,i need to trigger a task in dag. For this I have to do below:
But I don't see the connection type option for DB2 (screenshot attached). Do I have to install something? Please help.
PS: I am new to Airflow.
Upvotes: 0
Views: 2225
Reputation: 3
I have tried to connect to DB2 successfully on Airflow 2.2.5.
Airflow doesn't has specific provider for DB2. You need to use JDBC to connect. So you need to install some libraries of Airflow and download DB2 JDBC driver to fulfill this task. List of all libs and provider need to install below:
You also need to download DB2 JDBC drivers. This driver include some packages and license file like:
Because it will use JDBC to connect,openJDK also need to install on your docker. Setting environment variables JAVA_HOME, PATH and CLASSPATH are needed.
All of above actions can be done on your docker file.
When you have completed to build your image, You can start your airflow to set connection.
Connection URL syntax: jdbc:db2://Host:Port/Database You can replace HOST,PORT and Database.
Driver Path: You can input where your class file(db2jcc4.jar) located.
Hope these tips can help you. I am New to Airflow too.
Upvotes: 0
Reputation: 26
Yes the airflow connection does not appear to be a specific connection for db2, so you have to choose generic in connection Type.
I also recommend to install the security mechanism for connection.
the next package: pip install airflow-provider-db2
Upvotes: 0
Reputation: 15921
There is no DB2 specific connection.
For general connections you can just use the Generic connection:
For older Airflow versions that doesn't have Generic connection you can use any other connection type (HTTP/MySql for example). It doesn't really matter. Airflow looks for connection by the connection id. The type is almost meaningless in that perspective.
Upvotes: 1