add tags field

This commit is contained in:
pengtao 2019-11-04 11:22:56 +08:00
parent 78eba472f8
commit fb425f4157

View File

@ -3,7 +3,6 @@ from ops.mmysql import MysqlBase
from ops.plog import define_logger from ops.plog import define_logger
import logging import logging
import datetime import datetime
from collections import defaultdict
import pdb import pdb
define_logger("/data/logs/ops/split_tags.log") define_logger("/data/logs/ops/split_tags.log")
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -21,8 +20,7 @@ class SplitTapTags:
def run(self): def run(self):
all = dict() all = dict()
for types in self.type: for types in self.type:
pdb.set_trace() all[types] = {}
all[types] = defaultdict[dict]
sql = f"""select sql = f"""select
tags tags
from from
@ -36,7 +34,7 @@ class SplitTapTags:
if line: if line:
try: try:
for item in line[0].split(","): for item in line[0].split(","):
all[types][item] = all[types].get('item', 0) + 1 all[types][item] = all[types].get(item, 0) + 1
except Exception: except Exception:
log.error(f"split {line} failed!", exc_info=True) log.error(f"split {line} failed!", exc_info=True)
print(all) print(all)