24 lines
578 B
Python
24 lines
578 B
Python
# -*- coding: utf-8 -*-
|
|
"""数据加载器基类"""
|
|
|
|
import logging
|
|
|
|
|
|
class BaseLoader:
|
|
"""数据加载器基类"""
|
|
|
|
def __init__(self, db_ops, logger=None):
|
|
self.db = db_ops
|
|
self.logger = logger or logging.getLogger(self.__class__.__name__)
|
|
|
|
def upsert(self, records: list) -> tuple:
|
|
"""
|
|
执行 UPSERT 操作
|
|
返回: (inserted_count, updated_count, skipped_count)
|
|
"""
|
|
raise NotImplementedError("子类需实现 upsert 方法")
|
|
|
|
def _batch_size(self) -> int:
|
|
"""批次大小"""
|
|
return 1000
|