Skip to main content

Example: Sync a MySQL Table to Databend

Read the Overview first for authentication, request conventions, and errors.

An agent can do these steps with one API token. Each step names the endpoint.

  1. Check that the connection works. Call Test a Data Source Connection with serviceId: 2 and mysqlCredentials.
  2. Save the data source. Call Create a Data Source with the same body. Keep the returned id.
  3. Find the source tables. Call List MySQL Tables. For several databases, call Preview MySQL Table Rules instead.
  4. Choose a warehouse. Call List Warehouses.
  5. Create the task. Call Create a Task with mysqlTask.syncMode: 3. Keep the returned id.
  6. Start the task. Call Operate Tasks with operate: 1.
  7. Watch the progress. Call Get a Task and read taskStatus and lastRunData.mysqlLastRun. For trends, call Get Sync Metrics with queryType: MySQLSync.
  8. If the run fails, call List Task Runs and Get Task Run Details, and read responseData.error.
  9. Check the data. Run SELECT count(*) FROM raw_shop.orders through the Query API.

Steps 2, 5, and 6 change resources and can cost credits. Ask the user to confirm them before you call them.