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
3edac953
authored
Oct 10, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
insert into redis
parent
c33241e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
update_jd_attr.py
update_jd_attr.py
View file @
3edac953
...
...
@@ -138,11 +138,11 @@ def update_ext_attr_by_class_ids(conf: dict):
"""
基于lie_shop_attr中的class_id来更新 “拓展” 属性
"""
host
=
conf
[
"host"
]
port
=
conf
[
"port"
]
user
=
conf
[
"user"
]
password
=
conf
[
"password"
]
database
=
conf
[
"database"
]
host
=
conf
[
"
mysql"
][
"
host"
]
port
=
conf
[
"
mysql"
][
"
port"
]
user
=
conf
[
"
mysql"
][
"
user"
]
password
=
conf
[
"
mysql"
][
"
password"
]
database
=
conf
[
"
mysql"
][
"
database"
]
db
=
pymysql
.
connect
(
host
=
host
,
port
=
port
,
user
=
user
,
password
=
password
,
database
=
database
)
select_sql
=
"select distinct class_id from lie_shop_attr"
cursor
=
db
.
cursor
()
...
...
@@ -174,6 +174,7 @@ def update_ext_attr_by_class_ids(conf: dict):
if
flag
!=
1
:
continue
attr_id
=
result
[
"att_id"
]
class_attr_mapping
[
class_id
]
.
append
(
attr_id
)
attr_name
=
result
[
"name"
]
unit
=
result
[
"val_unit"
]
is_required
=
1
...
...
@@ -215,6 +216,7 @@ def update_ext_attr_by_class_ids(conf: dict):
print
(
insert_sql
%
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
))
else
:
update_sql
=
""
insert_ext_attr_to_redis
(
class_attr_mapping
,
conf
)
...
...
@@ -239,6 +241,9 @@ def insert_ext_attr_to_redis(class_attr_map: dict, conf: dict):
for
class_id
in
class_attr_map
:
key
=
str
(
class_id
)
attr_ids
=
class_attr_map
[
class_id
]
if
len
(
attr_ids
)
==
0
:
# 为空的直接跳过
continue
value
=
json
.
dumps
(
attr_ids
,
ensure_ascii
=
False
)
db
.
hset
(
name
=
"jd_ext_attr"
,
key
=
key
,
value
=
value
)
...
...
@@ -257,4 +262,5 @@ if __name__ == '__main__':
config
=
config_dev
elif
environment
==
"prod"
:
config
=
config_prod
update_jd_attr_by_class
(
conf
=
config
)
# update_jd_attr_by_class(conf=config)
# update_ext_attr_by_class_ids(conf=config)
\ 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