SQLite CDC 同步引擎
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
Metadata
Release files for sqlite-cdc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlite_cdc-0.1.0.tar.gz | 128.6 kB | Without provenance | Details for sqlite_cdc-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlite_cdc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sqlite_cdc-0.1.0-py3-none-any.whl |
Total release size: 174.9 kB
Release files / sqlite_cdc-0.1.0.tar.gz
| Download URL | sqlite_cdc-0.1.0.tar.gz |
|---|---|
| Size | 128.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ea475fe5f3b2247821200a48e1865420ca89ec47e66dd08de2b4d9bd69056de
|
|
BLAKE2b-256 checksum How to use checksums |
b782cbc8bf61815d248913e404a0f5bd2b4fbe7160ec83f66380feaf2f1594ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / sqlite_cdc-0.1.0-py3-none-any.whl
| Download URL | sqlite_cdc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64627934159e55998cb4b8fd6aa580915302545695e645b6463a00836ff76516
|
|
BLAKE2b-256 checksum How to use checksums |
2390b2d825098dc034ee3befff5e6dfa186b8124847c49f12263936b227b6aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for sqlite-cdc 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.