Skip to main content

SQLite CDC 同步引擎 - 支持存量和增量同步到 MySQL/Oracle

Project description

SQLite CDC 同步引擎

Build status Python 3.11+ License: MIT

SQLite CDC 同步引擎是一个 Python 库和 CLI 工具,用于将 SQLite 数据库的变更实时同步到 MySQL 或 Oracle 数据库。 代码由Claude Code + Kimi-K2.5 + spec-kit 生成,人工进行少量微调与验证,用于体验Vibe Coding能力,同时作为小规模场景下生产环境使用。

特性

  • CDC 变更捕获: 通过审计日志表捕获 SQLite 数据变更
  • 双模式同步: 支持存量数据全量同步和增量实时同步
  • 多目标支持: 可同时同步到多个 MySQL/Oracle 目标库
  • 字段映射: 支持字段名映射和值转换
  • 最终一致性: 断点续传、幂等写入保证 exactly-once 语义
  • CLI + 库: 既可作为命令行工具使用,也可作为 Python 库集成

快速开始

安装

pip install sqlite-cdc

命令行使用

# 生成配置模板
sqlite-cdc init sync.yaml

# 执行同步(存量 + 增量)
sqlite-cdc sync --config sync.yaml --mode full

Python 库使用

import asyncio
from sqlite_cdc import SyncEngine, load_config

async def main():
    config = await load_config("sync.yaml")
    engine = SyncEngine(config)
    await engine.start()

if __name__ == "__main__":
    asyncio.run(main())

配置示例

source:
  db_path: "./app.db"
  tables: ["users", "orders"]

targets:
  - name: "mysql_prod"
    type: "mysql"
    connection:
      host: "localhost"
      port: 3306
      database: "backup"
      username: "${MYSQL_USER}"
      password: "${MYSQL_PASSWORD}"

mappings:
  - source_table: "users"
    target_table: "users_backup"
    field_mappings:
      - source_field: "email"
        converter: "lowercase"

batch_size: 100
checkpoint_interval: 10

文档

开发

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
make test

# 代码检查
make lint

# 格式化代码
make format

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlite_cdc-0.1.0.tar.gz (128.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlite_cdc-0.1.0-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file sqlite_cdc-0.1.0.tar.gz.

File metadata

  • Download URL: sqlite_cdc-0.1.0.tar.gz
  • Upload date:
  • Size: 128.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for sqlite_cdc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ea475fe5f3b2247821200a48e1865420ca89ec47e66dd08de2b4d9bd69056de
MD5 c1f1c18f72c97281dde086318621869f
BLAKE2b-256 b782cbc8bf61815d248913e404a0f5bd2b4fbe7160ec83f66380feaf2f1594ed

See more details on using hashes here.

File details

Details for the file sqlite_cdc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sqlite_cdc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 46.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for sqlite_cdc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64627934159e55998cb4b8fd6aa580915302545695e645b6463a00836ff76516
MD5 455f1495371e6fcea91fa90c52f2f7dc
BLAKE2b-256 2390b2d825098dc034ee3befff5e6dfa186b8124847c49f12263936b227b6aa7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page