Add credentials
- Create a new pipeline or open an existing pipeline.
- Expand the left side of your screen to view the file browser.
- Scroll down and click on a file named
io_config.yaml. - Enter the following keys and values under the key named
default(you can have multiple profiles, add it under whichever is relevant to you)
Standard connection
SSH tunnel connection
Only in Mage Pro.Try our fully managed solution to access this advanced feature.
MYSQL_SSH_HOST: Hostname or IP of the SSH bastion.MYSQL_SSH_PORT: SSH port (default 22).MYSQL_SSH_USERNAME: SSH user to log in as.MYSQL_SSH_PKEY: Path to private key file (preferred).MYSQL_SSH_PASSWORD: Password for SSH user (alternative to key).
MYSQL_SSH_PKEY or MYSQL_SSH_PASSWORD, not both.
Using SQL block
- Create a new pipeline or open an existing pipeline.
- Add a data loader, transformer, or data exporter block.
- Select
SQL. - Under the
Data provider/Connectiondropdown, selectMysql. - Under the
Profiledropdown, selectdefault(or the profile you added credentials underneath). - Enter the optional table name of the table to write to.
- Under the
Write policydropdown, selectReplaceorAppend(please see SQL blocks guide for more information on write policies). - Enter in this test query:
SELECT 1. - Run the block.
Using Python block
Using MySQL connector
Using Mage’s MySQL python blocks
- Create a Data Loader block from the MySQL Template
- Create a Data Exporter block from the MySQL Template
- Custom types
overwrite_types dict in data exporter config
Here is an example code snippet:
Method arguments
| Field name | Description | Example values |
|---|---|---|
| allow_reserved_words | Whether to allow using reserved words as column names. | True/False (default: False) |
| auto_clean_name | Whether to automatically clean the column name (replace the empty space with underscore, avoid using number as the prefix of the column name) | True/False (default: True) |
| case_sensitive | Whether to support case sensitive columns | True/False (default: False) |
| drop_table_on_replace | Whether to drop the table when “if_exists” param is set to “replace”. | True/False (default: False) |
| if_exists | Specify resolution policy if table name already exists | ”fail”/“replace”/“append” (default: “replace”) |
| overwrite_types | Overwrite the column types | {'column1': 'INTEGER', 'column2': 'VARCHAR(255)'} |
| unique_conflict_method | How to handle the conflict on unique constraints. Use ‘UPDATE’ for UPSERT (update existing rows, insert new ones) or ‘IGNORE’ to skip duplicates. | ‘UPDATE’ or ‘IGNORE’ (default: None) |
| unique_constraints | The unique constraints of the table. Used with unique_conflict_method for UPSERT operations. | [‘col1’, ‘col2’] (default: None) |