Commit f7773e9a by lzzzzl

更新attr_values mongo处理

parent d8769c5d
Showing with 8 additions and 7 deletions
...@@ -10,8 +10,8 @@ user = parse.quote_plus("ichunt") ...@@ -10,8 +10,8 @@ user = parse.quote_plus("ichunt")
# pwd = parse.quote_plus("huntmon6699") # pwd = parse.quote_plus("huntmon6699")
pwd = parse.quote_plus("huntmon66499") pwd = parse.quote_plus("huntmon66499")
# myclient = pymongo.MongoClient("mongodb://{0}:{1}@192.168.1.237:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd)) myclient = pymongo.MongoClient("mongodb://{0}:{1}@192.168.1.237:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd))
myclient = pymongo.MongoClient("mongodb://{0}:{1}@172.18.137.23:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd)) # myclient = pymongo.MongoClient("mongodb://{0}:{1}@172.18.137.23:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd))
mydb = myclient['ichunt'] mydb = myclient['ichunt']
mycol = mydb["spu_attrs"] mycol = mydb["spu_attrs"]
...@@ -38,12 +38,13 @@ class ParamMongo(object): ...@@ -38,12 +38,13 @@ class ParamMongo(object):
for row in data: for row in data:
try: try:
spu_id = row[0] spu_id = row[0]
attr_values = str(json.loads(row[1])).split(",") attr_values = json.loads(row[1])
new_av_list = list() new_av_list = list()
for av in attr_values: for vals in attr_values:
attr_name = self.mysql_handler.get_attr_name(av[0]) val = str(vals).split(",")
attr_value = self.mysql_handler.get_attr_value(av[1]) attr_name = self.mysql_handler.get_attr_name(val[0])
attr_unit = self.mysql_handler.get_attr_unit(av[2]) attr_value = self.mysql_handler.get_attr_value(val[1])
attr_unit = self.mysql_handler.get_attr_unit(val[2])
if attr_name and attr_value and attr_unit: if attr_name and attr_value and attr_unit:
new_av_list.append({'attr_name': attr_name, 'attr_value': attr_value, 'attr_unit': attr_unit}) new_av_list.append({'attr_name': attr_name, 'attr_value': attr_value, 'attr_unit': attr_unit})
self.search_mongo(spu_id, new_av_list) self.search_mongo(spu_id, new_av_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment