:mod:`airflow.hooks.mysql_hook` =============================== .. py:module:: airflow.hooks.mysql_hook Module Contents --------------- .. py:class:: MySqlHook(*args, **kwargs) Bases: :class:`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. Note: For AWS IAM authentication, use iam in the extra connection parameters and set it to true. Leave the password field empty. This will use the the "aws_default" connection to get the temporary token unless you override in extras. extras example: ``{"iam":true, "aws_conn_id":"my_aws_conn"}`` .. attribute:: conn_name_attr :annotation: = mysql_conn_id .. attribute:: default_conn_name :annotation: = mysql_default .. attribute:: supports_autocommit :annotation: = True .. method:: set_autocommit(self, conn, autocommit) MySql connection sets autocommit in a different way. .. method:: get_autocommit(self, conn) MySql connection gets autocommit in a different way. :param conn: connection to get autocommit setting from. :type conn: connection object. :return: connection autocommit setting :rtype: bool .. method:: get_conn(self) Returns a mysql connection object .. method:: bulk_load(self, table, tmp_file) Loads a tab-delimited file into a database table .. method:: bulk_dump(self, table, tmp_file) Dumps a database table into a tab-delimited file .. staticmethod:: _serialize_cell(cell, conn) MySQLdb converts an argument to a literal when passing those separately to execute. Hence, this method does nothing. :param cell: The cell to insert into the table :type cell: object :param conn: The database connection :type conn: connection object :return: The same cell :rtype: object .. method:: get_iam_token(self, conn) Uses AWSHook to retrieve a temporary password to connect to MySQL Port is required. If none is provided, default 3306 is used