Commit ef63d255 by 岳巧源

add py

parent 011daeb1
Showing with 20 additions and 1 deletions
......@@ -5,6 +5,7 @@
# 映射组装后推送到 go_nplm_server处理
import json
import pymysql
import redis
db = redis.Redis(host='192.168.1.235', port=6379, password='icDb29mLy2s', decode_responses=True)
......@@ -27,8 +28,25 @@ def get_channel_info():
data["platform"] = platform
return data
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,))
results = cursor.fetchall()
data = []
for i in range(len(results)):
data.append(results[i][0])
return data
def int_to_str(a) -> str:
return str(a)
if __name__ == '__main__':
get_channel_info()
condition = get_channel_info()
ans = period_get_data("liexin_sku_0", "lie_sku_0", condition)
print(ans)
\ 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