You can export data results from TD to Shopify using CLI (TD Toolbelt).
This feature is in BETA version. For more information, contact your Customer Success Representative.
- TD Toolbelt is installed.
- Basic knowledge of Shopify and Shopify credentials.
The query result must match require columns(name & data type) with resource type
| Action | Resource | Column require | Query | Note |
|---|---|---|---|---|
| Update | [metafield_id: Integer, value: any] | SELECT metafield_id, value FROM table | ||
| Create | Shop | [key: String, namespace: String, value: any] | SELECT key, namespace, value FROM table | |
| Create | Product | [product_id: Integer, key: String, namespace: String, value: any] | SELECT product_id, key, namespace, value FROM table ORDER BY product_id | Please use ORDER BY to increase performance |
| Create | Product Variant | [variant_id: Integer, key: String, namespace: String, value: any] | SELECT variant_id, key, namespace, value FROM table ORDER BY variant_id | Please use ORDER BY to increase performance |
| Create | Product Image | [product_id: Integer, image_id: Integer, key: String, namespace: String, value: any] | SELECT product_id, image_id, key, namespace, value FROM table ORDER BY product_id, image_id | Please use ORDER BY to increase performance |
| Create | Custom Collection | [custom_collection_id: Integer, key: String, namespace: String, value: any] | SELECT custom_collection_id, key, namespace, value FROM table ORDER BY custom_collection_id | Please use ORDER BY to increase performance |
| Create | Smart Collection | [smart_collection_id: Integer, key: String, namespace: String, value: any] | SELECT smart_collection_id, key, namespace, value FROM table ORDER BY smart_collection_id | Please use ORDER BY to increase performance |
| Create | Customer | [customer_id: Integer, key: String, namespace: String, value: any] | SELECT customer_id, key, namespace, value FROM table ORDER BY customer_id | Please use ORDER BY to increase performance |
| Create | Order | [order_id: Integer, key: String, namespace: String, value: any] | SELECT order_id, key, namespace, value FROM table ORDER BY order_id | Please use ORDER BY to increase performance |
| Create | Draft Order | [draft_order_id: Integer, key: String, namespace: String, value: any] | SELECT draft_order_id, key, namespace, value FROM table ORDER BY draft_order_id | Please use ORDER BY to increase performance |
| Create | Blog | [blog_id: Integer, key: String, namespace: String, value: any] | SELECT blog_id, key, namespace, value FROM table ORDER BY blog_id | Please use ORDER BY to increase performance |
| Create | Article | [blog_id: Integer, article_id: Integer, key: String, namespace: String, value: any] | SELECT blog_id, article_id, key, namespace, value FROM table ORDER BY blog_id, article_id | Please use ORDER BY to increase performance |
| Create | Page | [page_id: Integer, key: String, namespace: String, value: any] | SELECT page_id, key, namespace, value FROM table ORDER BY page_id | Please use ORDER BY to increase performance |
You can use the CLI to configure your connection.
td query --database your_database
--result configuration queryThe following table identifies the configuration keys with descriptions.
| Config Key | Type | Required | Description |
|---|
Open a terminal and run the following command to install the newest Treasure Data Toolbelt.
Configuration keys and descriptions are as follows:
| Config Key | Type | Required | Description |
|---|---|---|---|
type | string | yes | shopify_metafield |
api_key | string | Yes | Shopify API Key. |
password | string | Yes | Shopify password. |
store_name | string | Yes | Your Store Name from Shopify |
| string | Yes | Only accept: create or update
|
resource | string | Yes (for action: create) | Only accept value:
|
| stop_on_failed_record | boolean | No | If checked, export jobs will terminate if an error record occurs. If left unchecked, export jobs still proceed even if a metafield created/updated failed. |
td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "shop",
"stop_on_failed_record": false
}' \
"SELECT page_id, key, namespace, value FROM table ORDER BY page_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "product",
"stop_on_failed_record": false
}' \
"SELECT product_id, key, namespace, value FROM table ORDER BY product_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "product_variant",
"stop_on_failed_record": false
}' \
"SELECT variant_id, key, namespace, value FROM table ORDER BY variant_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "product_image",
"stop_on_failed_record": false
}' \
"SELECT product_id, image_id, key, namespace, value FROM table ORDER BY product_id, image_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "custom_collection",
"stop_on_failed_record": false
}' \
"SELECT custom_collection_id, key, namespace, value FROM table ORDER BY custom_collection_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "smart_collection",
"stop_on_failed_record": false
}' \
"SELECT smart_collection_id, key, namespace, value FROM table ORDER BY smart_collection_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "customer",
"stop_on_failed_record": false
}' \
"SELECT customer_id, key, namespace, value FROM table ORDER BY customer_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "order",
"stop_on_failed_record": false
}' \
"SELECT order_id, key, namespace, value FROM table ORDER BY order_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "draft_order",
"stop_on_failed_record": false
}' \
"SELECT draft_order_id, key, namespace, value FROM table ORDER BY draft_order_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "blog",
"stop_on_failed_record": false
}' \
"SELECT blog_id, key, namespace, value FROM table ORDER BY blog_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "article",
"stop_on_failed_record": false
}' \
"SELECT blog_id, article_id, key, namespace, value FROM table ORDER BY blog_id, article_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "create",
"resource": "page",
"stop_on_failed_record": false
}' \
"SELECT page_id, key, namespace, value FROM table ORDER BY page_id"td query \
--database my_db \
--result '{
"type": "shopify_metafield",
"apikey": "xxxx",
"password": "xxxx",
"store_name": "xxxxx",
"action": "update",
"stop_on_failed_record": false
}' \
"SELECT metafield_id, value FROM table"