airflow.hooks.mysql_hook

Module Contents

class airflow.hooks.mysql_hook.MySqlHook(*args, **kwargs)[source]

Bases:airflow.hooks.dbapi_hook.DbApiHook

Interact with MySQL.

You can specify charset in the extra field of your connection as {"charset": "utf8"}. Also you can choose cursor as {"cursor": "SSCursor"}. Refer to the MySQLdb.cursors for more details.

conn_name_attr = mysql_conn_id[source]
default_conn_name = mysql_default[source]
supports_autocommit = True[source]
set_autocommit(self, conn, autocommit)[source]

MySql connection sets autocommit in a different way.

get_autocommit(self, conn)[source]

MySql connection gets autocommit in a different way.

Parameters

conn (connection object.) – connection to get autocommit setting from.

Returns

connection autocommit setting

Return type

bool

get_conn(self)[source]

Returns a mysql connection object

bulk_load(self, table, tmp_file)[source]

Loads a tab-delimited file into a database table

bulk_dump(self, table, tmp_file)[source]

Dumps a database table into a tab-delimited file

static _serialize_cell(cell, conn)[source]

MySQLdb converts an argument to a literal when passing those separately to execute. Hence, this method does nothing.

Parameters
  • cell (object) – The cell to insert into the table

  • conn (connection object) – The database connection

Returns

The same cell

Return type

object