airflow.models.connection

Module Contents

Classes

Connection

Placeholder to store information about different database instances

Functions

parse_netloc_to_hostname(*args, **kwargs)

This method is deprecated.

Attributes

log

airflow.models.connection.log[source]
airflow.models.connection.parse_netloc_to_hostname(*args, **kwargs)[source]

This method is deprecated.

class airflow.models.connection.Connection(conn_id=None, conn_type=None, description=None, host=None, login=None, password=None, schema=None, port=None, extra=None, uri=None)[source]

Bases: airflow.models.base.Base, airflow.utils.log.logging_mixin.LoggingMixin

Placeholder to store information about different database instances connection information. The idea here is that scripts use references to database instances (conn_id) instead of hard coding hostname, logins and passwords when using operators or hooks.

See also

For more information on how to use this class, see: Managing Connections

Parameters
  • conn_id (Optional[str]) -- The connection ID.

  • conn_type (Optional[str]) -- The connection type.

  • description (Optional[str]) -- The connection description.

  • host (Optional[str]) -- The host.

  • login (Optional[str]) -- The login.

  • password (Optional[str]) -- The password.

  • schema (Optional[str]) -- The schema.

  • port (Optional[int]) -- The port number.

  • extra (Optional[Union[str, dict]]) -- Extra metadata. Non-standard data such as private/SSH keys can be saved here. JSON encoded object.

  • uri (Optional[str]) -- URI address describing connection parameters.

EXTRA_KEY = __extra__[source]
__tablename__ = connection[source]
id[source]
conn_id[source]
conn_type[source]
description[source]
host[source]
schema[source]
login[source]
port[source]
is_encrypted[source]
is_extra_encrypted[source]
on_db_load(self)[source]
parse_from_uri(self, **uri)[source]

This method is deprecated. Please use uri parameter in constructor.

get_uri(self)[source]

Return connection in URI format

get_password(self)[source]

Return encrypted password.

set_password(self, value)[source]

Encrypt password and set in object attribute.

property password(cls)[source]

Password. The value is decrypted/encrypted when reading/setting the value.

get_extra(self)[source]

Return encrypted extra-data.

set_extra(self, value)[source]

Encrypt extra-data and save in object attribute to object.

property extra(cls)[source]

Extra data. The value is decrypted/encrypted when reading/setting the value.

rotate_fernet_key(self)[source]

Encrypts data with a new key. See: Fernet

get_hook(self, *, hook_params=None)[source]

Return hook based on conn_type

__repr__(self)[source]

Return repr(self).

log_info(self)[source]

This method is deprecated. You can read each field individually or use the default representation (__repr__).

debug_info(self)[source]

This method is deprecated. You can read each field individually or use the default representation (__repr__).

test_connection(self)[source]

Calls out get_hook method and executes test_connection method on that.

property extra_dejson(self)[source]

Returns the extra property by deserializing json.

classmethod get_connection_from_secrets(cls, conn_id)[source]

Get connection by conn_id.

Parameters

conn_id (str) -- connection id

Returns

connection

Return type

Connection

classmethod from_json(cls, value, conn_id=None)[source]

Was this entry helpful?