Community研究與資料分析github.com

24601/surreal-skills

從 MongoDB、PostgreSQL、MySQL、Neo4j、Kafka 和 JSONL 進行資料遷移與同步到 SurrealDB。支援完整與增量 CDC 同步。屬於 surreal-skills 系列。

surreal-skills 是什麼?

Surreal-Sync 是一個 CLI 工具,專為將資料從多種來源遷移到 SurrealDB 而設計,支援完整同步與基於變更資料捕獲(CDC)的增量同步。此技能涵蓋 MongoDB(透過變更串流)、MySQL(觸發器式 CDC)、PostgreSQL(觸發器或 wal2json 邏輯複寫)、Neo4j(時間戳追蹤)、Apache Kafka(消費者去重)及 JSONL 檔案(批次匯入)等來源。使用者可以透過單一命令列介面模式自動推導結構、建立關聯邊,並利用檢查點進行可恢復的同步。該工具在 Claude Code 與 Cursor 中運作良好,能簡化將既有資料庫遷移至 SurrealDB 的流程,特別適合現代應用開發與即時資料整合。

相容平台~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 進行增量 CDC(wal2json)
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 <來源> <命令> \
  --connection-string [連線字串] \
  --surreal-endpoint [SURREAL 端點] \
  --surreal-username [SURREAL 使用者名稱] \
  --surreal-password [SURREAL 密碼] \
  --to-namespace <命名空間> \
  --to-database <資料庫>

主要功能

  • 自動推導結構並建立 SurrealDB 資料表
  • 從來源主鍵進行記錄 ID 對應
  • 關係萃取與圖形邊建立
  • 可設定的批次大小與平行度
  • 可恢復的同步,附帶檢查點追蹤
  • Kafka 消費者去重

完整文件

請參閱主要技能的規則檔案以獲得完整指引:

Individual skills in this repo

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

相關技能