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
0d8d6228
authored
Oct 10, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add redis hset
parent
c4c0d8d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
update_jd_attr.py
update_jd_attr.py
View file @
0d8d6228
...
...
@@ -20,7 +20,9 @@ config_dev = {
"database"
:
"liexin_data_distribution"
},
"redis"
:
{
"host"
:
"192.168.1.235"
,
"port"
:
6379
,
"password"
:
"icDb29mLy2s"
}
}
...
...
@@ -154,8 +156,10 @@ def update_ext_attr_by_class_ids(conf: dict):
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
app_key
=
"CA52430E90209F51D8F5D7B615DDE9AD"
app_secret
=
"c92691b2379c48de87e699c4c2f7fb32"
class_attr_mapping
=
{}
for
i
in
range
(
len
(
class_ids
)):
class_id
=
class_ids
[
i
]
class_attr_mapping
[
class_id
]
=
[]
param
=
{
"category_leaf_id"
:
class_id
,
}
...
...
@@ -214,7 +218,7 @@ def update_ext_attr_by_class_ids(conf: dict):
def
insert_ext_attr_to_redis
(
class_attr_map
:
dict
):
def
insert_ext_attr_to_redis
(
class_attr_map
:
dict
,
conf
:
dict
):
"""
拓展属性存到 redis中
key : jd_ext_attr
...
...
@@ -228,6 +232,16 @@ def insert_ext_attr_to_redis(class_attr_map: dict):
33471: [1001074361, 236705]
}
"""
host
=
conf
[
"redis"
][
"host"
]
port
=
conf
[
"redis"
][
"port"
]
password
=
conf
[
"redis"
][
"password"
]
db
=
redis
.
Redis
(
host
=
host
,
port
=
port
,
password
=
password
,
decode_responses
=
True
)
for
class_id
in
class_attr_map
:
key
=
str
(
class_id
)
attr_ids
=
class_attr_map
[
class_id
]
value
=
json
.
dumps
(
attr_ids
,
ensure_ascii
=
False
)
db
.
hset
(
name
=
"jd_ext_attr"
,
key
=
key
,
value
=
value
)
...
...
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