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
b862635f
authored
Sep 29, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add attr
parent
8e37e7a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
update_jd_attr.py
update_jd_attr.py
View file @
b862635f
...
...
@@ -50,6 +50,9 @@ def insert_class_of_attr(class_id: int):
for
j
in
range
(
len
(
props
)):
class_id
=
class_id
attr_id
=
props
[
j
][
"id"
]
ex
=
check_class_and_attr
(
class_id
,
attr_id
)
if
ex
:
continue
attr_name
=
props
[
j
][
"name"
]
unit
=
props
[
j
][
"val_unit"
]
input_type
=
props
[
j
][
"input_type"
]
...
...
@@ -81,8 +84,8 @@ def insert_class_of_attr(class_id: int):
exists
=
check_class_and_attr
(
class_id
,
attr_id
)
if
not
exists
:
insert_sql
=
"insert into lie_shop_attr (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
#
cursor.execute(insert_sql, args=(class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time,))
#
db.commit()
cursor
.
execute
(
insert_sql
,
args
=
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
,))
db
.
commit
()
print
(
insert_sql
%
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
))
...
...
@@ -98,7 +101,36 @@ def insert_class_of_ext_attr(class_id: int):
app_secret
=
app_secret
,
param
=
{
"category_leaf_id"
:
class_id
}
)
print
(
json
.
dumps
(
data
,
ensure_ascii
=
False
))
# print(json.dumps(data,ensure_ascii=False))
if
"result"
in
data
[
"jingdong_vc_item_extProps_find_responce"
][
"jos_result_dto"
]:
results
=
data
[
"jingdong_vc_item_extProps_find_responce"
][
"jos_result_dto"
][
"result"
]
for
i
in
range
(
len
(
results
)):
attr_id
=
results
[
i
][
"att_id"
]
exists
=
check_class_and_attr
(
class_id
,
attr_id
)
if
not
exists
:
attr_name
=
results
[
i
][
"name"
]
unit
=
results
[
i
][
"val_unit"
]
ext_prop_value
=
results
[
i
][
"ext_prop_value"
]
lists
=
[]
for
j
in
range
(
len
(
ext_prop_value
)):
item
=
dict
()
item
[
"attr_value_id"
]
=
ext_prop_value
[
j
][
"value_id"
]
item
[
"attr_value_name"
]
=
ext_prop_value
[
j
][
"value_name"
]
lists
.
append
(
item
)
enum_value
=
json
.
dumps
(
lists
,
ensure_ascii
=
False
)
input_type
=
results
[
i
][
"input_type"
]
if
results
[
i
][
"is_required"
]
==
1
:
is_required
=
1
else
:
is_required
=
0
status
=
1
platform
=
1
create_time
=
int
(
time
.
time
())
insert_sql
=
"insert into lie_shop_attr (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
cursor
.
execute
(
query
=
insert_sql
,
args
=
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
,))
db
.
commit
()
print
(
insert_sql
%
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
))
...
...
@@ -107,4 +139,5 @@ if __name__ == '__main__':
class_ids
=
get_class_ids
()
for
i
in
range
(
len
(
class_ids
)):
class_id
=
class_ids
[
i
]
insert_class_of_attr
(
class_id
)
\ No newline at end of file
insert_class_of_attr
(
class_id
)
insert_class_of_ext_attr
(
class_id
)
\ No newline at end of file
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