查看类别

按计划将 DuckDB 同步到 Anvil.works。

自动化 · DuckDB 到 Anvil.works

保持 Anvil.works 与你的 DuckDB 文件保持一致, 按计划

只需编写一次 SQL 语句。Query Streams 会按照您设定的计划运行它,从每五分钟一次到每周一次都可以,并将结果行写入您的 Anvil.works 数据表。您可以按键匹配行,这样编辑操作就会生效,而查询未覆盖的行则会被删除,或者也可以简单地追加数据。无需 Zapier、脚本或导出功能。首次运行大约需要十五分钟,免费套餐即可满足需求。

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

你最终会得到什么

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

DuckDB holds your data in a file. Your team works in Anvil.works. The usual bridge is a hand-written import in your app 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 Anvil.works in one pass, matching rows by a key so the data table stays correct rather than growing.

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

你需要准备什么

查询流帐户

免费版足以满足本指南的需求。请注册: 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。

您的 Anvil.works 登录信息

输入 Anvil 应用的 HTTPS 地址,以及您在应用中使用 querystreams 模块的 connector.init_connector("key") 设置的连接器密钥。Query Streams 会检查应用的响应并列出其数据表。

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

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 连接(尚未连接?) 从这里开始),并在 Anvil.works 中编写 SELECT 语句,使其返回所需的行和列。以下示例从中提取几列。 命令 桌子:

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

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

  2. 打开自动化并选择 Anvil.works

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

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

  3. 连接 Anvil.works

    在 步骤 2 该页面将引导您完成 Anvil 端的操作:将 Query Streams 依赖项代码添加到您的应用程序中。 设置 → 依赖项 → 第三方创建一个服务器模块 从查询流导入连接器 和 connector.init_connector("你的密钥")然后点击 生成安全密钥 制作那把钥匙。然后输入你的 Anvil 应用网址 和 连接器身份验证密钥 并点击 测试连接您的应用需要 加速表 已开启(设置→数据表);页面会自动为您重新检查。

  4. 选择行的落点。

    在 步骤 3 选择 数据表 数据行应该会同步到该表中。如果您想要一个空表,请先在 Anvil 应用中创建它。如果表中已有数据行,预览会显示这些数据行,并解释每种同步模式会对其执行哪些操作。每个表只能设置一个自动化流程。

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

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

    追加 · 快速

    附加

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

    完全同步 · 镜像

    完全同步

    行通过以下方式匹配: 钥匙 例如订单 ID 这样的列。新行会被添加,已更改的行会就地更新,查询不再返回的行会被删除,包括用户手动输入到数据表中的行,因此请将手动输入的行保存在另一个数据表中。这是库存、销售管道、主数据和仪表盘的理想选择。

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

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

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

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

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

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

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

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

    给它一个 集成名称例如“每日发往 Anvil.works 的订单”,请检查 准备创建 摘要和点击 创建自动化返回“自动化”页面,按 运行 现在就执行第一次同步,无需等待预定计划。打开 Anvil.works 文件:行就在那里,位于列标题下方。

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

你之后看到的

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

它会在停止时通知你。

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

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

如果 Anvil.works 停止接受连接,或者数据连接器被删除,自动化流程将暂停并显示原因。重新连接或选择新的数据源,然后点击“恢复”。其他错误会继续执行计划,并在相应行中显示。

密钥必须唯一

每次执行完整同步之前,查询流都会检查查询结果中的键值是否唯一,如果不是,则会拒绝运行,从而避免任何未写入的数据进入数据表。请将键列保留在 Anvil 中;同步过程中不会删除查询中未识别的列。

这些计划允许什么?

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

计划每次运行的行数
免费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.

人们提出的问题

同步操作会覆盖我的团队在 Anvil.works 中添加的笔记吗?

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

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

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

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

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

我可以稍后修改查询吗?

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

两个自动化脚本可以写入同一个数据表吗?

不,每个数据表只能有一个自动化流程。第二个自动化流程可以指向不同的数据表,或者扩展第一个自动化流程背后的查询范围。

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

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

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

每份指南 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