# OracleData2Dm **Repository Path**: wangxin59521/oracle-data2-dm ## Basic Information - **Project Name**: OracleData2Dm - **Description**: # Oracle到DM数据库数据迁移工具 这是一个用于将数据从Oracle数据库迁移到达梦数据库(DM)的工具。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-14 - **Last Updated**: 2025-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Oracle到DM数据库数据迁移工具 这是一个用于将数据从Oracle数据库迁移到达梦数据库(DM)的工具。 ## 功能特性 - 支持全表数据迁移 - 支持指定表迁移 - 支持批量数据处理 - 支持迁移进度显示 - 自动生成迁移报告 ## 环境依赖 - Python 3.6+ - Oracle客户端库 - 达梦数据库客户端 ## 安装步骤 1. 安装Python 3.6或更高版本 2. 安装依赖包: ```bash pip install -r requirements.txt ``` 3. 如果在安装过程中遇到oracledb相关的编译问题,可以考虑使用cx_Oracle作为替代方案: ```bash pip install --only-binary=all cx_Oracle ``` ## 配置文件 创建或修改config.yaml文件,配置源数据库和目标数据库连接信息: ```yaml source_db: host: localhost port: 1521 service_name: ORCL username: your_username password: your_password target_db: host: localhost port: 5236 service_name: DAMENG username: your_username password: your_password # 可选: 指定要迁移的表,不设置则迁移所有表 tables_to_migrate: - TABLE1 - TABLE2 # 可选: 指定要排除的表 tables_to_exclude: - LOG_TABLE # 可选: 批量大小,默认为1000 batch_size: 1000 # 可选: 重试次数,默认为3 retry_count: 3 ``` ## 使用方法 ### 直接运行 ```bash python main.py [配置文件路径,默认为config.yaml] ``` ### 打包运行 1. Linux环境下使用build.sh脚本打包: ```bash ./build.sh ./dist/oracle2dm [配置文件路径] ``` 2. Windows环境下使用Docker打包: ```bash docker build -t oracle2dm . docker run --rm -v $(pwd):/data oracle2dm /data/config.yaml ``` ## 常见问题 ### 打包后执行报错 "No module named 'cryptography'" 或相关模块 这是因为在使用 PyInstaller 打包时没有包含 cryptography 模块及其子模块,该模块是 oracledb 在 thin 模式下必需的依赖。 解决方案: 1. 确保 requirements.txt 中包含了 cryptography 依赖 2. 在使用 PyInstaller 打包时添加以下参数: ```bash pyinstaller --onefile \ --hidden-import=cryptography \ --hidden-import=cryptography.x509 \ --hidden-import=cryptography.hazmat.backends.openssl.backend \ --hidden-import=cryptography.hazmat.bindings._openssl \ --hidden-import=cryptography.hazmat.primitives.kdf \ --hidden-import=cryptography.hazmat.primitives.kdf.pbkdf2 \ --hidden-import=oracledb \ main.py ``` 或者使用更简单的收集所有 cryptography 模块的方式: ```bash pyinstaller --onefile --collect-all cryptography main.py ``` ### 安装oracledb时出现编译错误 在某些Windows环境下,安装oracledb可能会出现编译错误,可以使用cx_Oracle作为替代方案: ```bash pip install --only-binary=all cx_Oracle==8.3.0 ``` 然后修改main.py中的导入语句: ```python try: import oracledb except ImportError: import cx_Oracle as oracledb ``` ### 打包后执行报错 "[CODE:-70090]加密模块版本不匹配" 这是由于打包环境和运行环境中的达梦数据库客户端库版本不一致导致的加密模块冲突。 解决方案: 1. 在build.sh脚本中添加对dmPython模块的完整收集: ```bash pyinstaller --onefile \ --hidden-import=dmPython \ --collect-all dmPython \ main.py ``` 2. 确保打包环境和运行环境使用相同版本的达梦数据库客户端库。 3. 如果问题仍然存在,建议在目标机器上直接运行而非打包运行: ```bash python main.py config.yaml ```