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.
- Check that the connection works. Call Test a Data Source Connection with
serviceId: 2andmysqlCredentials. - Save the data source. Call Create a Data Source with the same body. Keep the returned
id. - Find the source tables. Call List MySQL Tables. For several databases, call Preview MySQL Table Rules instead.
- Choose a warehouse. Call List Warehouses.
- Create the task. Call Create a Task with
mysqlTask.syncMode: 3. Keep the returnedid. - Start the task. Call Operate Tasks with
operate: 1. - Watch the progress. Call Get a Task and read
taskStatusandlastRunData.mysqlLastRun. For trends, call Get Sync Metrics withqueryType: MySQLSync. - If the run fails, call List Task Runs and Get Task Run Details, and read
responseData.error. - Check the data. Run
SELECT count(*) FROM raw_shop.ordersthrough the Query API.
Steps 2, 5, and 6 change resources and can cost credits. Ask the user to confirm them before you call them.