airflow.providers.ibm.db2.hooks.db2

This module allows to connect to an IBM Db2 database.

Classes

Db2Hook

Interact with IBM Db2.

Module Contents

class airflow.providers.ibm.db2.hooks.db2.Db2Hook(*args, schema=None, log_sql=True, **kwargs)[source]

Bases: airflow.providers.common.sql.hooks.sql.DbApiHook

Interact with IBM Db2.

You can specify SSL and other connection parameters in the extra field of your connection.

SSL Configuration: - {"SECURITY": "SSL", "SSLServerCertificate": "/path/to/cert.crt"} - For SSL with server certificate - {"SECURITY": "SSL"} - For SSL without certificate validation

Other Parameters: Any additional Db2 connection string parameters can be added to the extra field. Parameter names will be automatically converted to uppercase.

Parameters:

db2_conn_id – The Db2 connection id reference to a specific Db2 database.

conn_name_attr = 'db2_conn_id'[source]
default_conn_name = 'db2_default'[source]
conn_type = 'ibmdb2'[source]
hook_name = 'IBM Db2'[source]
supports_autocommit = True[source]
supports_executemany = True[source]
property dialect_name: str[source]
property dialect: airflow.providers.ibm.db2.dialects.db2.Db2Dialect[source]
get_conn()[source]

Return ibm_db_dbi connection object.

Returns:

Db2 connection object

Return type:

Any

get_uri()[source]

Return connection URI for SQLAlchemy using the ibm-db-sa dialect.

Includes extra connection parameters (like SSL configuration) as query parameters.

Returns:

SQLAlchemy connection URI

Return type:

str

get_column_names(table, schema=None)[source]

Get column names for a table, excluding identity columns.

Delegates to Db2Dialect.get_column_names(), which filters out columns that Db2 marks as autoincrement=True (i.e. GENERATED ALWAYS AS IDENTITY).

Parameters:
  • table (str) – Table name

  • schema (str | None) – Schema name (optional)

Returns:

Column names excluding identity columns

Return type:

list[str] | None

get_primary_keys(table, schema=None)[source]

Get primary key column names for a table.

Delegates to Db2Dialect.get_primary_keys().

Parameters:
  • table (str) – Table name

  • schema (str | None) – Schema name (optional)

Returns:

List of primary key column names

Return type:

list[str] | None

Was this entry helpful?