https://github.com/oaklight/onehub-database-sync
https://github.com/oaklight/onehub-database-sync
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/oaklight/onehub-database-sync
- Owner: Oaklight
- License: mit
- Created: 2025-03-17T22:17:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-17T22:18:54.000Z (about 1 year ago)
- Last Synced: 2025-03-17T23:27:08.556Z (about 1 year ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# One-Hub 数据库迁移工具
本工具专为 MartialBE/one-hub 项目设计,提供 SQLite 和 PostgreSQL 数据库之间的双向同步功能,支持以下特性:
## 功能特性
- 针对 one-hub 数据库结构优化
- SQLite 到 PostgreSQL 的迁移
- PostgreSQL 到 SQLite 的同步
- 云端 PostgreSQL 与本地 PostgreSQL 之间的双向同步
- 自动处理 one-hub 特定数据类型转换
## 适用版本
- SQLite: 3.x
- PostgreSQL: 16
## 快速开始
1. 复制 `config.toml.sample` 为 `config.toml` 并配置数据库连接信息
2. 安装依赖:`pip install -r requirements.txt`
3. 运行相应脚本:
- SQLite 到 PostgreSQL 迁移:`python migrate_sqlite_to_pg.py`
- PostgreSQL 双向同步:`python sync_pg.py [cloud-to-local|local-to-cloud]`
## 配置说明
配置文件 `config.toml` 包含以下配置项:
- `database`: SQLite 数据库配置
- `postgresql.cloud`: 云端 PostgreSQL 配置
- `postgresql.local`: 本地 PostgreSQL 配置
## 注意事项
- 同步前请备份重要数据
- 确保数据库版本兼容
- 同步过程中请保持网络连接稳定
## 许可证
MIT License