查看类别

按计划将 DuckDB 同步到 Google Sheets

自动化 · DuckDB 到 Google Sheets

保持 谷歌工作表 与你的 DuckDB 文件保持一致, 按计划

只需编写一次 SQL 语句。Query Streams 会按照您设定的计划运行它,从每五分钟一次到每周一次都可以,并将结果写入您的 Google Sheets 表格。您可以按键匹配行,这样编辑操作就会保留在原处,而查询未覆盖的行则会被删除,或者也可以简单地追加数据。无需 Zapier、脚本或导出功能。首次运行大约需要十五分钟,而且免费套餐就包含了这项服务。

大约15分钟 无需编程 文件位置不变 每 5 分钟到每周
遇到任何问题?尽管问我们。 打开 支持 请在“查询流”(右上角菜单 → 支持)中给我们发送消息。我们会安排专人阅读您的消息,“我不知道这个屏幕需要什么”就是一个很好的问题。

你最终会得到什么

DuckDB 标志一个 Google Sheets 表格,用于存储 DuckDB 查询返回的数据行,并按计划更新,更新频率从每五分钟一次到每周一次不等,每次更新后都会生成一份变更记录。例如:

DuckDB holds your data in a file. Your team works in Google Sheets. The usual bridge is an Apps Script or a Zapier zap that breaks quietly and copies one row at a time. Query Streams Automation does it differently: the Agent that already reads your DuckDB file runs your saved SQL on a schedule and writes the whole result into Google Sheets in one pass, matching rows by a key so the sheet stays correct rather than growing.

文件存放位置办公室电脑、服务器或家里的电脑你的 DuckDB 文件sales.duckdb · 保留在此处查询流代理运行已保存的查询按你的时间表查询流加密链接仅记录 · 我们不会读回这些行你的团队在哪里工作任何浏览器,任何设备谷歌工作表您的表格已就地更新
代理程序会管理您的数据,并在预定时间运行查询。Google 表格只会接收这些数据行。无需任何人进行任何操作。

你需要准备什么

查询流帐户

免费版足以满足本指南的需求。请注册: my.querystreams.com.

DuckDB 通过 Agent 连接

The Agent installed on the computer that holds your DuckDB file, or on one that reads it from a network share, with the connection added in Data Agents. Not done yet? 首先连接 DuckDB大约需要十分钟。

已保存的查询

您希望保持同步的 SELECT 语句,已保存在 查询生成器下面的步骤 1 展示了一个例子。如果您希望更改的行直接更新,请添加一个每行唯一的列,例如 ID。

您的 Google Sheets 登录信息

Google 要求您仅允许查询流查看和编辑您选择的电子表格。它无法查看您云端硬盘中的其他任何内容。

工作在哪里进行? 在运行代理程序的计算机上,它会按计划运行查询并将结果写入 Google Sheets,因此该计算机需要保持开机状态。您可以关闭浏览器。查询流本身不会存储这些行。

File on another computer? The Agent does not have to run on the computer that holds your DuckDB file: it can read the file from a network share. Reaching a file on a network share, below, shows what that takes.

分六步完成设置

  1. 保存要保持同步的查询

    打开 查询生成器选择你的 DuckDB 连接(尚未连接?) 从这里开始),并编写 SELECT 语句,使其返回 Google Sheets 中所需的确切行和列。以下示例从中提取几列: 命令 桌子:

    示例 · SQL
    SELECT order_id, customer_name, order_total FROM main.orders ORDER BY order_total DESC LIMIT 100;

    运行它,然后 节省 给它起一个你容易识别的名字,例如“Google Sheets 订单”。在 SELECT 语句中,保留每行唯一的列,如下所示。 订单ID这就是完全同步功能用于就地更新行的关键所在。稍后编辑并重新保存查询,自动化程序会在下次运行时获取到这些更改。

  2. 打开自动化功能,选择 Google 表格。

    在门户中,打开 自动化 (顶部菜单) 流 → 定时 → 自动化)并点击 新自动化巫师有五个简单的步骤。 步骤 1 点击 谷歌工作表 卡片。

    看到的是“开始之前”吗? 只有当代理在线并建立连接且至少存在一个已保存的查询时,该向导才会打开。页面会列出缺少哪一项,并提供指向该查询的链接。

  3. 连接 Google 表格

    在 步骤 2 点击 连接到 Google 表格一个 Google 窗口打开;登录并允许访问。Google 会询问您是否允许 Query Streams 仅查看和编辑您选择的电子表格。它无法查看您云端硬盘中的其他任何内容。已经连接过一次?该页面会提供 使用此连接 反而。

  4. 选择行的落点。

    在 步骤 3 选择 电子表格: 点击 从 Google 云端硬盘中选择 然后在 Google 文件选择器中选择它,或者在下方输入名称。 创建新电子表格 并点击 创造然后选择 床单 (标签页)。每个标签页只能执行一个自动化流程;如果某个标签页已被其他自动化流程写入,则会显示为已占用。

  5. 选择查询语句,并决定如何显示数据行。

    在 步骤 4 打开 保存的查询 列出并选择步骤 1 中的查询。查询流会运行一次该查询以读取列,并告诉您返回的行数,以及两个选项:

    追加 · 快速

    附加

    每次运行都会将查询结果添加到工作表底部。不会更新或删除任何数据,因此它是快速收集日志、事件和历史记录的理想选择。无需键列。未更改的行不会重复添加;值发生更改的行会作为新行添加到下方,而原行保留。

    完全同步 · 镜像

    完全同步

    行通过以下方式匹配: 钥匙 例如订单 ID 列。系统会添加新行,更新已更改的行,并删除查询结果不再返回的行,包括用户手动输入的行,因此请将手动输入的行保存在另一个标签页中。此方法适用于库存、销售管道、主数据和仪表盘。

    完全同步是按列设置的,这使得它在共享工作表中非常有用:

    钥匙
    例如,标识行的列。 订单ID它在查询结果中必须是唯一的;查询流会自动检查这一点并拒绝重复项。
    同步
    每次运行都会覆盖 DuckDB 中的数据。如果有人在 Google Sheets 中编辑了同步列,下次运行会恢复源值。
    保存
    该数据行在首次到达时写入,之后不会再进行比较,因此 DuckDB 中对该行的更改不会触发更新。对于团队手动输入的备注、所有者和后续日期,请使用完全不在查询中的列:仅存在于 Google Sheets 中的列永远不会被同步操作修改。

    哪个更快? 追加写入操作不会先读取工作表。完全同步操作会读取工作表,比较每一行,然后只写入差异部分,因此耗时更长,但工作表始终与查询结果完全匹配。您可以稍后从自动化流程的“编辑”面板中切换操作方式。

    如果你想查看一份值得信赖的表格,请点击 将所有列设置为同步然后点击钥匙图标 订单ID 使其成为 钥匙查询流会扫描整个结果以确认键的唯一性,如果不是,则会发出警告。您可以将团队的备注保存在与查询无关的列中;这些列不会被修改。要查看只会不断增长的日志,请点击此处。 将所有列设置为保留 而是跳过密钥。点击 继续.

  6. 设置日程,命名,创建它

    在 步骤 5 选择 按计划运行 并选择 频率:

    频率跑
    每5分钟每 5 分钟一次,最快允许时间
    每15分钟每隔15分钟
    每隔30分钟每隔30分钟
    每小时每小时整点
    每天上午9点每天上午 9:00,默认
    每天早上6点每天早上6点
    工作日上午9点周一至周五上午 9:00
    每周一(上午 9 点)每周一上午9:00
    自定义日程您自己的分钟、小时、星期几或月份几日。

    时代如是 时区 你选择,它最初是你浏览器的默认设置。你也可以选择 仅限手动 并按 运行 您可以随时设置计划任务;稍后可以从自动化流程的“编辑”面板添加计划任务。计划任务会在代理程序上运行,因此即使浏览器关闭,任务也会继续运行。如果运行代理程序的计算机在任务到期时处于关机状态,则会在代理程序重新启动后不久执行一次错过的运行。

    给它一个 集成名称例如“每日将订单导入 Google 表格”,请检查 准备创建 摘要和点击 创建自动化返回“自动化”页面,按 运行 现在就进行第一次同步,无需等待预定的同步时间。打开 Google 表格:行就在那里,位于列标题下方。

就是这样。 从现在开始,表格会自动更新。除了查询返回的行之外,没有任何数据会离开您的网络,而且无需任何人手动运行任何操作。

你之后看到的

这 自动化页面 列出所有自动化流程及其状态、源、目标、键、计划、上次同步时间和行数。打开一个查看详情。 执行 标签页:记录每次运行及其触发条件(手动或计划)、持续时间以及创建、更新、删除和未更改的行数。 表现 该标签页显示 7 至 90 天内处理的数据和成功率。

它会在停止时通知你。

每个组织都有 同步问题 从第一天起就设置了警报规则:同步失败时发送应用内通知和电子邮件,同步恢复后再发送一封邮件。每次事件只发送一条消息,不会每次重试都发送一条消息。您可以关闭此功能或在“流”→“警报和报告”中更改渠道。

它会在应该暂停的时候暂停。

如果 Google Sheets 停止接受连接,或者数据连接器被删除,自动化流程将暂停并显示原因。重新连接或选择新的数据源,然后点击“继续”。其他错误不会影响流程的正常运行,并在相应行中显示。

关键列缺失

如果有人重命名或删除 Google 表格中的关键列,则在写入任何内容之前,完全同步会停止并显示相关信息。 修复选项:恢复表头并重新运行,或者重新开始。同步操作不会删除其他列。

这些计划允许什么?

所有套餐(包括免费套餐)都包含自动化功能,且创建的自动化数量没有限制。每个套餐的限制在于每次查询运行返回的行数:

计划每次运行的行数
免费125
个人核心500
个人加强版1,000
核心业务2,500
商务+5,000
商业最大10,000
企业核心25,000
企业增强版100,000
企业版 Max250,000

如果查询返回的结果较多,则运行会继续进行而不是提前终止,自动化流程会告知您哪个计划更合适,或者建议添加筛选条件,例如日期范围。每次成功运行都会占用您的数据域配额,该配额与您的 Excel 和 Sheets 查询使用的配额相同。 请查看定价页面 津贴。

下一步行动不错。

  • 添加筛选器 查询条件可以是最近 90 天的数据,这样表格就能保持小巧快速,并且符合您计划的行数限制。
  • 将手写笔记单独列保存。位于查询之外,因此它们在每次同步中都能保留下来。
  • 将自动化流程分组 在编辑面板中添加几个元素后,自动化页面会按组进行筛选。

Reaching a file on a network share

The Agent opens files as a background service, not as you, so a file on another computer needs one extra step. Which step depends on the computer the Agent runs on.

Windows

Type the network path, like \\服务器\共享\文件夹, never a mapped drive letter such as S:, which the Agent cannot see. If the share only lets in named people, click Service identity (the chip under the path) and store a login for that server: a company domain account, or an account made on the server itself with Domain left blank. The Agent then signs in to that server and reads the file there, and every connector on that Agent that reads the same server must use the same login. Without a login, it reads as its own service account, which a company domain sees as the computer itself. Step by step on Windows

Linux

Share logins stored in the Portal are not used on Linux: an administrator mounts the share on the Agent’s computer first, in a folder under /mnt 或 /媒体, because the Agent’s service cannot see /home 或 /run/user. In the connector, keep the \\server\share path, which the Agent maps onto the mount, or type the mount path instead, such as /mnt/fileserver-shared/Accounts. How to mount a share on Linux

苹果

Share logins stored in the Portal are not used on a Mac: mount the share first from Terminal with sudo, in a folder under /Volumes, so the Agent’s background service can see it. In the connector, keep the \\server\share path, which the Agent maps onto the mount, or type the mount path instead, such as /Volumes/fileserver-shared/Accounts. How to mount a share on a Mac

If the test cannot get to the share, look for these words in its result: unreachable means the Agent’s computer got no answer from the server. On Linux or a Mac, not mounted means the share still has to be mounted, and that message includes the exact mount command for your server.

DuckDB file on a share? DuckDB allows one writer at a time, so the Agent cannot open a file that another program has open for writing; on a \\server\share path the test says it is open for writing by another program. Close it there, or point the connector at a file nobody is writing to. Every query reads the file across the network, so a large file answers more slowly than it would from a local disk.

Test failed on a share?

Every run reaches the file the same way the connection test does. If runs start failing after something changed on the file server, a new password for example, open the connector in 数据代理 并点击 测试连接. The test result, and the line under the file path, name the problem:

留言原因使固定
DuckDB database file not found: followed by a \\server\share path you know is rightNo login is stored, so the Agent tried the share as its own account and could not see the file: the share turned that account away, or the server did not answer. In the first case the line under the path says Access denied for the agent’s service account.点击 Service identity under the path and store a login that can read the share. If the line under the path does not say access denied, check that the Agent’s computer can open the share at all.
Share \\server: access denied — add credentials for this serverA login is stored, but that account has no permission on the share, or another sign-in to the same server is in the way; the message before this line says which.Ask whoever runs the server to give that account read access, or store an account that has it. For a sign-in in the way, see the two rows on one login per server below.
Share \\server: the credentials were refused — check the username and passwordThe server turned the stored login down: a typo, the wrong domain, or a password changed since it was saved, which also stops runs that used to work.Click the chip under the path and type the password again; for an account made on the server itself, leave Domain blank. After a refused login the Agent waits a minute before it tries that same one again, so the account is not locked out; saving a corrected password tries straight away.
Share \\server: server unreachable from the agent machineThe Agent’s computer got no answer from the server: a wrong server name, the server is off, or a firewall blocks file sharing.On the Agent’s computer, open the same \\server\share path in File Explorer. If that fails too, it is a network problem for whoever runs the network.
Another connector on this agent already signs in to \\server as …Windows lets one computer sign in to a server as one account at a time, and another connector on this Agent uses a different login for that server.Store the same login the other connector uses, or change it on every connector that reads that server.
Windows already holds a sign-in to \\server for …Something on the Agent’s computer other than the Agent is already signed in to that server as a different account, and the Agent never closes a sign-in it did not make.Do what the rest of the message says: use that same account on this connector, or close the other sign-in on the Agent’s computer. If it says the share is already readable through that sign-in, choose Use service identity in the login box instead.
This agent build cannot sign in to \\server with stored credentials.The Agent is an older version that cannot use stored logins.Update the Agent, then test again.
\\server\share is not mounted on this Linux agent (或) macOS agent)The Agent runs on Linux or a Mac and the share has not been mounted on its computer yet; logins stored in the Portal are not used there.Mount it with the command the message gives you, then test again. Step by step: 在 Linux 系统上 · on a Mac.
… is open for writing by another programDuckDB allows one writer at a time, and another program has the file open for writing.Close the file in that program, or point the connector at a file nobody is writing to.

人们提出的问题

同步操作会覆盖我的团队在 Google Sheets 中添加的笔记吗?

如果备注位于单独的列中,则不会出现这种情况。仅存在于 Google 表格中而不在您的查询中的列不会被修改,因此请在已同步的列旁边添加“备注”或“所有者”列,并在其中输入内容。标记的列 同步 每次运行时都会恢复到 DuckDB 的值; 保存 当数据行首次到达时,列会被填充,之后不再进行比较。

我的 DuckDB 数据会被查询流存储吗?

不。代理程序会在您这边运行查询,并通过加密链接将数据行直接发送到 Google Sheets。查询流保存的是配置、计划和每次运行的行数,而不是数据行本身。

我的电脑需要一直开着吗?

运行代理程序的电脑会执行此操作,因为代理程序负责运行查询并将数据写入 Google 表格。您自己的笔记本电脑和浏览器可以关闭。如果该电脑在查询到期时处于关机状态,则错过的查询会在代理程序重新启动后不久执行一次。

我可以稍后修改查询吗?

是的。在查询构建器中编辑并保存,下次运行时会自动使用新版本。如果添加或删除列,请打开自动化的编辑面板进行映射。

两个自动化脚本可以写入同一个标签页吗?

不,每个标签页只能有一个自动化流程。可以将第二个自动化流程指向不同的标签页,或者扩大第一个自动化流程背后的查询范围。

免费套餐真的包含这些吗?

是的。“免费”套餐是永久有效的,不是会过期的试用版。每个套餐都包含自动化功能;不同套餐的区别在于每次查询可以返回的行数。请查看“免费”套餐的具体内容。 定价页面.

还是不行? 打开 支持 请在“查询流”中告诉我们您当前处于第几步以及您看到的内容。我们会帮您连接。
同一个已保存的查询也可以与……保持同步AirtableSmartsheetBaserow海洋餐桌Anvil.works以及更多

每份指南 DuckDB

这不是你想要的配置?

  • 如果您的文件夹里是 Parquet 文件而不是 DuckDB 数据库文件,Parquet 文件夹会将它们全部读取为一个表 → Parquet Folder

Setup trouble?

  • Agent says the file or folder does not exist, or access is denied? Mapped drives, network shares, OneDrive and Linux home folders each need one fix → Where the Agent can read files from
  • Agent shows Offline, or Test connection and Browse are greyed out? Check that the Agent is online → Is the Agent online?
更新 10 月 12, 2026

Powered by BetterDocs