> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidocs.polytomic.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server.

# MySQL

Supports:
* ✅ Models
* ✅ Model sync destination
* ✅ Bulk sync source
* ✅ Bulk sync destination


## Connection

### Configuration
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>account</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Username</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>change_detection</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Use replication for bulk syncs</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>dbname</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Database (optional)</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>hostname</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Hostname</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>passwd</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Password</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>port</code></td>
<td><code>integer</code></td>
<td style="vertical-align: top;">Port</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>ssh</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Connect over SSH tunnel <a href="#ssh-true">↓</a></td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>ssl</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Use SSL</td>
<td><code>optional</code></td>
</tr>
</tbody>
</table>

<a id="ssh-true"></a>

#### `ssh`

When `ssh` is `true`:

<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ssh_host</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">SSH host</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>ssh_port</code></td>
<td><code>integer</code></td>
<td style="vertical-align: top;">SSH port</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>ssh_private_key</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Private key</td>
<td><code>required</code></td>
</tr>
<tr>
<td><code>ssh_user</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">SSH user</td>
<td><code>required</code></td>
</tr>
</tbody>
</table>

```json
{
  "name": "MySQL connection",
  "type": "mysql",
  "configuration": {
    "account": "admin",
    "change_detection": false,
    "dbname": "mydb",
    "hostname": "database.example.com",
    "passwd": "password",
    "port": 3306,
    "ssh": true,
    "ssh_host": "bastion.example.com",
    "ssh_port": 22,
    "ssh_private_key": "",
    "ssh_user": "root",
    "ssl": true
  }
}
```


#### Example

```json
{
  "name": "MySQL connection",
  "type": "mysql",
  "configuration": {
    "account": "admin",
    "change_detection": false,
    "dbname": "mydb",
    "hostname": "database.example.com",
    "passwd": "password",
    "port": 3306,
    "ssh": false,
    "ssl": true
  }
}
```


## Model Sync
### Source
#### Configuration
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>query</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;"></td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>table</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Table</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>view</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">View</td>
<td><code>optional</code></td>
</tr>
</tbody>
</table>


#### Example
```json
{
  ...
  "configuration": {
    "query": "SELECT * from users",
    "table": "users",
    "view": "active_users"
  }
}
```


### Target
MySQL connections may be used as the destination in a model sync.
#### All targets

##### Configuration
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>created_column</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">'Created at' timestamp column</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>preserve_table_on_resync</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Preserve destination table when resyncing</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>updated_column</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">'Updated at' timestamp column</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>write_null_values</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Copy null values<br/><br/>When enabled updates will set fields to NULL when the source value is null</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>write_record_timestamps</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Write row timestamp metadata</td>
<td><code>optional</code></td>
</tr>
</tbody>
</table>


##### Example
```json
{
  ...
  "target": {
      "configuration": {
        "created_column": "",
        "preserve_table_on_resync": false,
        "updated_column": "",
        "write_null_values": false,
        "write_record_timestamps": false
    }
  }
}
```






### Target creation

MySQL connections may be used to create a new target for a model sync. The
following parameters are required to create a new target:

<table>
<thead>
<tr>
  <th>NAME</th>
  <th>DESCRIPTION</th>
  <th>ENUM</th>
</tr></thead>
<tbody>
<tr>
  <td>name</td>
  <td>Table name</td>
  <td>false</td>
</tr>

</tbody>
</table>




## Bulk Sync
### Source
MySQL connections may be used as a bulk sync source. No additional configuration options are required.

### Destination
#### Configuration
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>advanced</code></td>
<td><code>object</code></td>
<td style="vertical-align: top;"></td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>mirror_schemas</code></td>
<td><code>boolean</code></td>
<td style="vertical-align: top;">Mirror schemas</td>
<td><code>optional</code></td>
</tr>
<tr>
<td><code>schema</code></td>
<td><code>string</code></td>
<td style="vertical-align: top;">Output schema</td>
<td><code>optional</code></td>
</tr>
</tbody>
</table>


#### Example
```json
{
  ...
  "destination_configuration": {
    "advanced": {
        "empty_strings_null": true,
        "hard_deletes": false,
        "initial_execution": "rebuild",
        "table_prefix": "",
        "truncate_existing": false
    },
    "mirror_schemas": false,
    "schema": "schema"
  }
}
```



## Type handling
### Destination types
|       POLYTOMIC TYPE        |         MYSQL TYPE         |
|-----------------------------|----------------------------|
| `array<>`                   | `JSON`                     |
| `bigint`                    | `BIGINT`                   |
| `boolean`                   | `BOOLEAN`                  |
| `date`                      | `DATE`                     |
| `datetime`                  | `DATETIME`                 |
| `decimal(precision, scale)` | `DECIMAL(precision,scale)` |
| `double`                    | `DOUBLE`                   |
| `int`                       | `INT`                      |
| `json`                      | `JSON`                     |
| `jsonarray`                 | `JSON`                     |
| `number`                    | `DECIMAL(65,30)`           |
| `object{}`                  | `JSON`                     |
| `single`                    | `FLOAT`                    |
| `smallint`                  | `SMALLINT`                 |
| `string`                    | `LONGTEXT`                 |
| `time`                      | `TIME`                     |


### Source types
|         MYSQL TYPE          |       POLYTOMIC TYPE        |
|-----------------------------|-----------------------------|
| `BIGINT`                    | `bigint`                    |
| `BIT`                       | `number`                    |
| `BLOB`                      | `binary`                    |
| `BLOB`                      | `string`                    |
| `CHAR`                      | `string`                    |
| `DATE`                      | `date`                      |
| `DATETIME`                  | `datetime`                  |
| `DECIMAL(precision, scale)` | `decimal(precision, scale)` |
| `DOUBLE`                    | `double`                    |
| `ENUM`                      | `string`                    |
| `FLOAT`                     | `single`                    |
| `INT`                       | `int`                       |
| `MEDIUMBLOB`                | `binary`                    |
| `MEDIUMINT`                 | `int`                       |
| `MEDIUMTEXT`                | `string`                    |
| `NUMERIC(precision, scale)` | `decimal(precision, scale)` |
| `SMALLINT`                  | `smallint`                  |
| `TEXT`                      | `string`                    |
| `TIME`                      | `time`                      |
| `TIMESTAMP`                 | `datetime`                  |
| `TINYBLOB`                  | `binary`                    |
| `TINYINT`                   | `smallint`                  |
| `TINYTEXT`                  | `string`                    |
| `UNSIGNED BIGINT`           | `bigint`                    |
| `UNSIGNED INT`              | `int`                       |
| `UNSIGNED SMALLINT`         | `smallint`                  |
| `UNSIGNED TINYINT`          | `smallint`                  |
| `VARBINARY`                 | `binary`                    |
| `VARCHAR`                   | `string`                    |
| `YEAR`                      | `int`                       |