MySQL行同步到Google表格
中级
这是一个Engineering领域的自动化工作流,包含 9 个节点。主要使用 If, MySql, GoogleSheets, ScheduleTrigger 等节点。 自动化MySQL到Google表格同步,含重复预防
前置要求
- •MySQL 数据库连接信息
- •Google Sheets API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "TmP9EhlzHlU4r1wS",
"meta": {
"instanceId": "ea2b41532677d34614d95d13d7d2ccb694657be482144baf71e7140df3b2a853",
"templateCredsSetupCompleted": true
},
"name": "将 MySQL 行同步到 Google Sheet",
"tags": [],
"nodes": [
{
"id": "a78b4dc6-b4c6-4ed8-8b9f-dad0a6897307",
"name": "从表中选择行",
"type": "n8n-nodes-base.mySql",
"position": [
-288,
-112
],
"parameters": {
"table": {
"value": "fifa25_customers"
},
"where": {
"values": [
{
"value": "=0",
"column": "sync"
}
]
},
"options": {},
"operation": "select"
},
"credentials": {
"mySql": {
"id": "HiSdj9EQPLInFlnQ",
"name": "MySQL-SaadeddinPastry"
}
},
"typeVersion": 2.4
},
{
"id": "b1a1e46f-4d7f-4068-a697-e35735af7718",
"name": "在表格中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
352,
-304
],
"parameters": {
"columns": {
"value": {
"id": "={{ $json.id }}",
"name": "={{ $json.name }}",
"email": "={{ $json.email }}",
"phone": "={{ $json.phone }}",
"gender": "={{ $json.gender }}",
"region": "={{ $json.region }}",
"datatime": "={{ $json.datatime }}",
"birthdate": "={{ $json.birthdate }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "phone",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "phone",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "birthdate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "birthdate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "region",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "region",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "gender",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "gender",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "datatime",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "datatime",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"value": "gid=0"
},
"documentId": {
"value": "1b86B_7Hcusp7ehDNjJZtCa8Rlmljf2av7Hs-gaSluoc"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "KJ3WD4ZJZo6YMqm3",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
},
{
"id": "e7f77e58-ddfc-4086-8016-6ebdd9d01d44",
"name": "更新表中的行",
"type": "n8n-nodes-base.mySql",
"position": [
352,
-128
],
"parameters": {
"table": {
"value": "fifa25_customers"
},
"options": {},
"dataMode": "defineBelow",
"operation": "update",
"valuesToSend": {
"values": [
{
"value": "1",
"column": "sync"
}
]
},
"valueToMatchOn": "={{ $json.id }}",
"columnToMatchOn": "id"
},
"credentials": {
"mySql": {
"id": "HiSdj9EQPLInFlnQ",
"name": "MySQL-SaadeddinPastry"
}
},
"typeVersion": 2.4
},
{
"id": "0aba12f9-2627-4be1-bd53-1505d332f352",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-336,
48
],
"parameters": {
"color": 3,
"width": 208,
"height": 80,
"content": "从 MySQL 表中获取 50 条未同步数据的记录"
},
"typeVersion": 1
},
{
"id": "2ad57e58-7f42-4ef3-8d3a-228fc8ab422b",
"name": "每 n 分钟调度触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-528,
-112
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 15
}
]
}
},
"typeVersion": 1.2
},
{
"id": "b52eebd6-1177-414e-8062-1204ac643dc9",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
304,
16
],
"parameters": {
"color": 3,
"width": 208,
"height": 80,
"content": "将所有获取的数据的 sync 列更新为 1,以防止下次运行时重复"
},
"typeVersion": 1
},
{
"id": "13a3b1e5-32b2-436f-9961-d924c9d052ef",
"name": "无操作,不执行任何操作",
"type": "n8n-nodes-base.noOp",
"position": [
352,
160
],
"parameters": {},
"typeVersion": 1
},
{
"id": "f82d841b-fbda-4eed-80e5-15fa83a6cc00",
"name": "检查是否返回新记录",
"type": "n8n-nodes-base.if",
"position": [
-80,
-112
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "fdc56e38-29be-42a1-baa8-3c4e2380b2c1",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ $jmespath($input.all(), '[].json').length }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d35b54c0-1bde-43d8-ad95-e79c9a5b3957",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
176,
-352
],
"parameters": {
"width": 400,
"height": 656,
"content": "## 输出"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "75f1c88c-35cb-4762-ba78-e19a2ca167bd",
"connections": {
"Select rows from a table": {
"main": [
[
{
"node": "Check if new record returned",
"type": "main",
"index": 0
}
]
]
},
"Check if new record returned": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
},
{
"node": "Update rows in a table",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger Every n Mins": {
"main": [
[
{
"node": "Select rows from a table",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工程
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 OpenAI、Google Sheets、Jina AI 和 Slack 的 AI 驱动信息监控
基于AI的信息监控,集成OpenAI、Google Sheets、Jina AI和Slack
If
Set
Code
+10
31 节点Dataki
销售
自动发送Vtiger支持工单到Telegram(含状态更新)
自动发送Vtiger支持工单到Telegram(含状态更新)
If
Telegram
Schedule Trigger
+3
7 节点Ahmed Saadawi
工单管理
自动向新Vtiger潜在客户发送欢迎WhatsApp消息
通过Evolution API WhatsApp自动向Vtiger CRM潜在客户发送欢迎消息
If
Schedule Trigger
Vtiger Node
+3
7 节点Ahmed Saadawi
客户培育
技术雷达
使用SQL数据库、RAG和路由代理构建AI驱动的技术雷达顾问
If
Code
Cron
+22
53 节点Sean Lon
工程
Airtable完整备份
Airtable数据库备份到S3
If
Set
Aws S3
+8
19 节点Autonomous Work
工程
Vtiger CRM通过DeepSeek LLM回答常见问题
使用DeepSeek LLM和LangChain在Vtiger CRM中自动生成FAQ答案
If
Agent
Schedule Trigger
+4
8 节点Ahmed Saadawi
内容创作