Commit 73c676cd by 岳巧源

add push sku

parent ef63d255
Showing with 9 additions and 7 deletions
......@@ -9,7 +9,7 @@ import pymysql
import redis
db = redis.Redis(host='192.168.1.235', port=6379, password='icDb29mLy2s', decode_responses=True)
db_234 = redis.Redis(host='192.168.1.234', port=6379, password='icDb29mLy1s', decode_responses=True)
def get_channel_info():
"""return supplier_id 或者 brand_id 等等"""
......@@ -32,7 +32,6 @@ def period_get_data(db_name, table_name, condition) -> list:
"""指定数据库 指定表中获取数据"""
db = pymysql.connect(host='192.168.1.238', port=3306, user='spu', password='spu', database=db_name)
supplier_ids = condition["supplier_id_list"]
placeholders = ", ".join(["%s"] * len(supplier_ids))
sql = "select spu_id from " + table_name + " where supplier_id in %s"
cursor = db.cursor()
cursor.execute(sql, args=(supplier_ids,))
......@@ -42,11 +41,14 @@ def period_get_data(db_name, table_name, condition) -> list:
data.append(results[i][0])
return data
def int_to_str(a) -> str:
return str(a)
def get_class_from_rds(spu_id):
"""根据spu_id 在redis中获取到对应的品牌和分类"""
infos = db_234.hget("spu", str(spu_id))
return json.loads(infos)
if __name__ == '__main__':
condition = get_channel_info()
ans = period_get_data("liexin_sku_0", "lie_sku_0", condition)
print(ans)
\ No newline at end of file
spu_ids = period_get_data("liexin_sku_0", "lie_sku_0", condition)
infos = get_class_from_rds(spu_ids[0])
print(type(infos))
\ No newline at end of file
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