Community研究与数据分析github.com

24601/surreal-skills

数据迁移和同步到 SurrealDB,支持 MongoDB、PostgreSQL、MySQL、Neo4j、Kafka 和 JSONL。提供全量同步和增量 CDC 同步。属于 surreal-skills 系列。

surreal-skills 是什么?

Surreal-Sync 是一个功能强大的 CLI 工具,专为将数据从多种常见数据库源迁移并同步到 SurrealDB 而设计。它支持全量同步和基于变更数据捕获(CDC)的增量同步,确保数据实时保持一致。该工具覆盖了 MongoDB、MySQL、PostgreSQL(通过触发器或 wal2json 逻辑复制)、Neo4j、Apache Kafka 以及 JSONL 文件等多种源,具有自动模式推断、记录 ID 映射、关系提取和图边创建等关键特性。用户可通过 Rust 的包管理器轻松安装,并利用统一的 CLI 模式快速配置连接、目标命名空间和数据库。此外,Surreal-Sync 支持可恢复的同步、可配置的批处理和并行度,以及 Kafka 消费者的去重,适用于生产环境下的高效数据集成。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/24601/surreal-skills/tree/main/skills/surreal-sync

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Surreal-Sync —— 数据迁移与同步

Surreal-Sync 是一个 CLI 工具,用于将数据从各种数据库源迁移到 SurrealDB,并通过变更数据捕获(CDC)实现全量同步和增量同步。

支持的源

源全量同步增量 CDC方法
MongoDB是是更改流
MySQL是是基于触发器的 CDC + 序列检查点
PostgreSQL(触发器)是是基于触发器的 CDC + 序列检查点
PostgreSQL(wal2json)是是使用 wal2json 插件的逻辑复制
Neo4j是是基于时间戳的跟踪
JSONL 文件是不适用从 JSON Lines 批量导入
Apache Kafka是是带去重的消费者订阅

快速开始

# 安装 surreal-sync(Rust 二进制文件)
cargo install surreal-sync

# 从 PostgreSQL(基于触发器)进行全量同步
surreal-sync from postgres trigger-full \
  --connection-string "postgresql://user:pass@localhost/mydb" \
  --surreal-endpoint "http://localhost:8000" \
  --surreal-username root \
  --surreal-password root \
  --to-namespace prod \
  --to-database main

# 从 PostgreSQL(wal2json)进行增量 CDC
surreal-sync from postgres wal2json \
  --connection-string "postgresql://user:pass@localhost/mydb" \
  --surreal-endpoint "http://localhost:8000" \
  --surreal-username root \
  --surreal-password root \
  --to-namespace prod \
  --to-database main

# 从 MongoDB 进行全量同步
surreal-sync from mongo full \
  --connection-string "mongodb://localhost:27017/mydb" \
  --surreal-endpoint "http://localhost:8000" \
  --surreal-username root \
  --surreal-password root \
  --to-namespace prod \
  --to-database main

# 从 JSONL 批量导入
surreal-sync from jsonl import \
  --file data.jsonl \
  --surreal-endpoint "http://localhost:8000" \
  --surreal-username root \
  --surreal-password root \
  --to-namespace prod \
  --to-database main

# 从 Kafka 消费
surreal-sync from kafka consume \
  --bootstrap-servers "localhost:9092" \
  --topic my-events \
  --surreal-endpoint "http://localhost:8000" \
  --surreal-username root \
  --surreal-password root \
  --to-namespace prod \
  --to-database main

CLI 模式

surreal-sync from <SOURCE> <COMMAND> \
  --connection-string [CONNECTION STRING] \
  --surreal-endpoint [SURREAL ENDPOINT] \
  --surreal-username [SURREAL USERNAME] \
  --surreal-password [SURREAL PASSWORD] \
  --to-namespace <NS> \
  --to-database <DB>

关键特性

  • 自动模式推断和 SurrealDB 表创建
  • 从源主键映射记录 ID
  • 关系提取和图边创建
  • 可配置的批处理大小和并行度
  • 带检查点跟踪的可恢复同步
  • Kafka 消费者的去重

完整文档

请参阅主技能的规则文件以获取完整指导:

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

相关技能