保持 Anvil.works 与您的 Access 文件同步, 按计划
只需编写一次 SQL 语句。Query Streams 会按照您设定的计划运行它,从每五分钟一次到每周一次都可以,并将结果行写入您的 Anvil.works 数据表。您可以按键匹配行,这样编辑操作就会生效,而查询未覆盖的行则会被删除,或者也可以简单地追加数据。无需 Zapier、脚本或导出功能。首次运行大约需要十五分钟,免费套餐即可满足需求。
你最终会得到什么
Anvil.works 数据表,用于存储 Access 查询返回的数据行,并按计划定期更新(每五分钟或每周一次),每次更新后都会生成一份更改记录。例如:
Microsoft Access 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 Access 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.
你需要准备什么
通过代理连接的访问权限
The Agent installed on the computer that holds your Access file, or on one that reads it from a network share, with the connection added in Data Agents. Not done yet? 首先连接访问大约需要十分钟。
您的 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 Access file: it can read the file from a network share. Reaching a file on a network share, below, shows what that takes.
分六步完成设置
-
保存要保持同步的查询
打开 查询生成器选择您的 Access 连接(尚未连接?) 从这里开始),并在 Anvil.works 中编写 SELECT 语句,使其返回所需的行和列。以下示例从中提取几列。 客户 桌子:
示例 · SQLSELECT TOP 100 CustomerID, CompanyName, City FROM Customers ORDER BY CompanyName;
运行它,然后 节省 给它起一个容易识别的名字,例如“Anvil.works 的订单”。在 SELECT 语句中保留一个每行都唯一的列,如下所示。 客户ID这就是完全同步功能用于就地更新行的关键所在。稍后编辑并重新保存查询,自动化程序会在下次运行时获取到这些更改。
-
打开自动化并选择 Anvil.works
在门户中,打开 自动化 (顶部菜单) 流 → 定时 → 自动化)并点击 新自动化巫师有五个简单的步骤。 步骤 1 点击 Anvil.works 卡片。
看到的是“开始之前”吗? 只有当代理在线并建立连接且至少存在一个已保存的查询时,该向导才会打开。页面会列出缺少哪一项,并提供指向该查询的链接。
-
连接 Anvil.works
在 步骤 2 该页面将引导您完成 Anvil 端的操作:将 Query Streams 依赖项代码添加到您的应用程序中。 设置 → 依赖项 → 第三方创建一个服务器模块
从查询流导入连接器和connector.init_connector("你的密钥")然后点击 生成安全密钥 制作那把钥匙。然后输入你的 Anvil 应用网址 和 连接器身份验证密钥 并点击 测试连接您的应用需要 加速表 已开启(设置→数据表);页面会自动为您重新检查。 -
选择行的落点。
在 步骤 3 选择 数据表 数据行应该会同步到该表中。如果您想要一个空表,请先在 Anvil 应用中创建它。如果表中已有数据行,预览会显示这些数据行,并解释每种同步模式会对其执行哪些操作。每个表只能设置一个自动化流程。
-
选择查询语句,并决定如何显示数据行。
在 步骤 4 打开 保存的查询 列出并选择步骤 1 中的查询。查询流会运行一次该查询以读取列,并告诉您返回的行数,以及两个选项:
追加 · 快速附加
每次运行都会将查询结果添加到数据表的底部。不会更新或删除任何数据,因此它是快速收集日志、事件和历史记录的理想选择。无需键列。未更改的行不会再次添加;值发生更改的行会作为新行添加到下方,而原行则保留。
完全同步 · 镜像完全同步
行通过以下方式匹配: 钥匙 例如订单 ID 这样的列。新行会被添加,已更改的行会就地更新,查询不再返回的行会被删除,包括用户手动输入到数据表中的行,因此请将手动输入的行保存在另一个数据表中。这是库存、销售管道、主数据和仪表盘的理想选择。
完全同步是按列设置的,这使得它在共享数据表中非常有用:
- 钥匙
- 例如,标识行的列。 订单ID它在查询结果中必须是唯一的;查询流会自动检查这一点并拒绝重复项。
- 同步
- 每次运行都会覆盖 Access 中的数据。如果有人在 Anvil.works 中编辑了同步列,下次运行会将源值恢复。
- 保存
- 该行数据在首次到达时写入,之后不再进行比较,因此在 Access 中对其进行更改不会触发更新。对于团队手动输入的备注、所有者和后续日期,请使用根本不在查询中的列:仅存在于 Anvil.works 中的列永远不会被同步操作修改。
哪个更快? 追加写入操作不会先读取数据表。完全同步操作会读取数据表,比较每一行,然后只写入差异部分,因此耗时更长,但数据表始终与查询结果完全匹配。您可以稍后在自动化流程的编辑面板中切换操作。
要查看您信任的数据表,请点击 将所有列设置为同步然后点击钥匙图标 客户ID 使其成为 钥匙查询流会扫描整个结果以确认键的唯一性,如果不是,则会发出警告。您可以将团队的备注保存在与查询无关的列中;这些列不会被修改。要查看只会不断增长的日志,请点击此处。 将所有列设置为保留 而是跳过密钥。点击 继续.
-
设置日程,命名,创建它
在 步骤 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 |
| 企业版 Max | 250,000 |
如果查询返回的结果较多,则运行会继续进行而不是提前终止,自动化流程会告知您哪个计划更合适,或者建议添加筛选条件,例如日期范围。每次成功运行都会占用您的数据域配额,该配额与您的 Excel 和 Sheets 查询使用的配额相同。 请查看定价页面 津贴。
下一步行动不错。
- 添加筛选器 查询条件可以是最近 90 天的数据,这样数据表就能保持较小且运行速度快,并符合计划的行数限制。
- 将手写笔记单独列保存。位于查询之外,因此它们在每次同步中都能保留下来。
- 将自动化流程分组 在编辑面板中添加几个元素后,自动化页面会按组进行筛选。
Reaching a file on a network share
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.
Microsoft Access file on a share? The account the Agent reads with needs Modify permission on the folder, because Access creates a .laccdb lock file beside the database even when it only reads. Do not run the Agent for Access on a computer with 32-bit Office; use a dedicated computer without it. Signing in to the file server · If the computer has 32-bit Office
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:
| 留言 | 原因 | 使固定 |
|---|---|---|
| Access database file does not exist: followed by a \\server\share path you know is right | No 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 server | A 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 password | The 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 machine | The 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. |
| The agent cannot write to the folder containing the Access database. | The account can read the file but cannot create the .laccdb lock file beside it. | Give that account Modify permission on the folder, the same as any Access user has. |
Messages about the database engine or Office are in the Microsoft Access connector guide’s Test failed? table.
人们提出的问题
同步操作会覆盖我的团队在 Anvil.works 中添加的笔记吗?
如果备注位于单独的列中,则不会发生这种情况。仅存在于 Anvil.works 中而不存在于您的查询中的列永远不会被修改,因此请在已同步的列旁边添加“备注”或“所有者”列,并在其中输入内容。标记的列 同步 每次运行时都会恢复到 Access 值; 保存 当数据行首次到达时,列会被填充,之后不再进行比较。
我的 Access 数据会被 Query Streams 存储吗?
不。代理程序会在您这边运行查询,并通过加密链接将查询结果直接发送到 Anvil.works。查询流保存的是配置、计划和每次运行的行数,而不是查询结果本身。
我的电脑需要一直开着吗?
运行代理程序的计算机负责执行查询并将数据写入 Anvil.works。您自己的笔记本电脑和浏览器可以关闭。如果在查询到期时计算机处于关机状态,则错过的查询会在代理程序重新启动后不久执行一次。
我可以稍后修改查询吗?
是的。在查询构建器中编辑并保存,下次运行时会自动使用新版本。如果添加或删除列,请打开自动化的编辑面板进行映射。
两个自动化脚本可以写入同一个数据表吗?
不,每个数据表只能有一个自动化流程。第二个自动化流程可以指向不同的数据表,或者扩展第一个自动化流程背后的查询范围。
免费套餐真的包含这些吗?
是的。“免费”套餐是永久有效的,不是会过期的试用版。每个套餐都包含自动化功能;不同套餐的区别在于每次查询可以返回的行数。请查看“免费”套餐的具体内容。 定价页面.
相关指南
每份指南 Access
Setup trouble?
- Access engine will not install, the file is on a mapped drive, or Test connection fails? The Access setup page walks each fix click by click → Microsoft Access connector setup
- Agent shows Offline, or Test connection and Browse are greyed out? Check that the Agent is online → Is the Agent online?

