forked from Boris-code/feapder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole_pipeline.py
More file actions
47 lines (36 loc) · 1.15 KB
/
Copy pathconsole_pipeline.py
File metadata and controls
47 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on 2021/3/18 12:39 上午
---------
@summary:
---------
@author: Boris
@email: boris_liu@foxmail.com
"""
from feapder.pipelines import BasePipeline
from typing import Dict, List, Tuple
class ConsolePipeline(BasePipeline):
"""
pipeline 是单线程的,批量保存数据的操作,不建议在这里写网络请求代码,如下载图片等
"""
def save_items(self, table, items: List[Dict]) -> bool:
"""
保存数据
Args:
table: 表名
items: 数据,[{},{},...]
Returns: 是否保存成功 True / False
若False,不会将本批数据入到去重库,以便再次入库
"""
return True
def update_items(self, table, items: List[Dict], update_keys=Tuple) -> bool:
"""
更新数据
Args:
table: 表名
items: 数据,[{},{},...]
update_keys: 更新的字段, 如 ("title", "publish_time")
Returns: 是否更新成功 True / False
若False,不会将本批数据入到去重库,以便再次入库
"""
return True