You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB

6 months ago
from connectors.mysql_connector import MySQLConnector
from connectors.clickhouse_connector import ClickHouseConnector
from mappers.data_mapper import DataMapper
from services.sync_service import SyncService
from utils.logger import configure_logger
5 months ago
from config.db_config import *
6 months ago
logger = configure_logger()
5 months ago
from config.tables_config import TABLE_CONFIG
6 months ago
def main():
# 初始化组件
mysql_conn = MySQLConnector(mysql_config)
ch_conn = ClickHouseConnector(ch_config)
5 months ago
# 创建同步服务(支持多表)
6 months ago
service = SyncService(
mysql_conn=mysql_conn,
ch_conn=ch_conn,
5 months ago
mapper=DataMapper(),
table_config=TABLE_CONFIG
6 months ago
)
try:
5 months ago
success, failed = service.sync_all_tables()
logger.info(f"同步完成:成功 {len(success)} 表,失败 {len(failed)}")
6 months ago
except Exception as e:
5 months ago
logger.error(f"全局同步失败: {str(e)}", exc_info=True)
6 months ago
finally:
ch_conn.disconnect()
if __name__ == "__main__":
main()