MySqlOperator¶
Use the MySqlOperator
to execute
SQL commands in a MySql database.
Using the Operator¶
Use the mysql_conn_id
argument to connect to your MySql instance where
the connection metadata is structured as follows:
Parameter |
Input |
---|---|
Host: string |
MySql hostname |
Schema: string |
Set schema to execute Sql operations on by default |
Login: string |
MySql user |
Password: string |
MySql user password |
Port: int |
MySql port |
An example usage of the MySqlOperator is as follows:
You can also use an external file to execute the SQL commands. Script folder must be at the same level as DAG.py file.
Note
Parameters that can be passed onto the operator will be given priority over the parameters already given
in the Airflow connection metadata (such as schema
, login
, password
and so forth).