Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
jd_data_process
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8084e333
authored
Oct 09, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add update and insert
parent
0c8c6ae3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletions
update_jd_attr.py
update_jd_attr.py
View file @
8084e333
...
@@ -5,6 +5,9 @@ import sys
...
@@ -5,6 +5,9 @@ import sys
import
pymysql
import
pymysql
from
common
import
request_to_jd_vc
from
common
import
request_to_jd_vc
# TODO 通知基石平台告警 ??? 是不是按照原来的方式?? 用is_mapping 字段来进行标识???
config_dev
=
{
config_dev
=
{
"host"
:
"192.168.1.238"
,
"host"
:
"192.168.1.238"
,
"port"
:
3306
,
"port"
:
3306
,
...
@@ -44,10 +47,34 @@ def update_jd_attr_by_class(conf: dict):
...
@@ -44,10 +47,34 @@ def update_jd_attr_by_class(conf: dict):
for
i
in
range
(
len
(
class_ids
)):
for
i
in
range
(
len
(
class_ids
)):
if
i
!=
0
:
if
i
!=
0
:
break
break
class_id
=
class_ids
[
i
]
param
=
{
param
=
{
"category_leaf_id"
:
class_id
s
[
i
]
"category_leaf_id"
:
class_id
}
}
ans
=
request_to_jd_vc
(
method_name
=
method_name
,
token
=
token
,
app_key
=
app_key
,
app_secret
=
app_secret
,
param
=
param
)
ans
=
request_to_jd_vc
(
method_name
=
method_name
,
token
=
token
,
app_key
=
app_key
,
app_secret
=
app_secret
,
param
=
param
)
# 处理京东返回的数据 并尝试修改db
jd_results
=
ans
[
"jingdong_vc_item_props_find_responce"
][
"jos_result_dto"
][
"result"
]
for
j
in
range
(
len
(
jd_results
)):
result
=
jd_results
[
j
]
props
=
result
[
"props"
]
for
k
in
range
(
len
(
props
)):
prop
=
props
[
k
]
# 对于 required 为false的数据, 直接跳过,不予处理
if
not
prop
[
"required"
]:
continue
# 对于 input_type 不同的数据 需要采用不同的处理方式。
# 检查这个属性id 是否已经存在(存在的情况会update, 不存在的情况会insert)
attr_id
=
prop
[
"id"
]
check_sql
=
"select id from lie_shop_attr where class_id =
%
s and attr_id =
%
s"
cursor
.
execute
(
query
=
check_sql
,
args
=
(
class_id
,
attr_id
))
db_result
=
cursor
.
fetchall
()
if
len
(
db_result
)
==
0
:
pass
else
:
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment