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
adc1f5c8
authored
Oct 28, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add pop update
parent
efbabccd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
crontab_pop.py
crontab_pop.py
View file @
adc1f5c8
"""
"""
拉取及更新pop店铺最新数据。
拉取及更新pop店铺最新数据。
"""
"""
from
common
import
request_to_jd_pop
import
pymysql
import
time
import
sys
config_dev
=
{
"mysql"
:
{
"host"
:
"192.168.1.238"
,
"port"
:
3306
,
"user"
:
"liexin_data_distribution"
,
"password"
:
"liexin_data_distribution#zsyM"
,
"database"
:
"liexin_data_distribution"
},
"redis"
:
{
"host"
:
"192.168.1.235"
,
"port"
:
6379
,
"password"
:
"icDb29mLy2s"
}
}
config_prod
=
{
"mysql"
:
{
"host"
:
"bigdata2.ichunt.db"
,
"port"
:
3306
,
"user"
:
"DsbuUx"
,
"password"
:
"sfj09JjsfpQx0"
,
"database"
:
"liexin_data_distribution"
},
"redis"
:
{
"host"
:
"172.18.137.38"
,
"port"
:
6379
,
"password"
:
"icDb29mLy2s"
}
}
def
update_pop_class
(
conf
:
dict
):
"""
更新pop得分类
"""
method_name
=
"jingdong.vender.category.getFullValidCategoryResultByVenderId"
token
=
"74ee3f2fa54d489da0d1b94ca83c9bc7lztn"
app_key
=
"CCE6563827D13EDF4769C01E7429378D"
app_secret
=
"98c72374c5b045529879786fc4e5c20e"
param
=
{
}
ans
=
request_to_jd_pop
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
data
=
ans
[
"jingdong_vender_category_getFullValidCategoryResultByVenderId_responce"
][
"returnType"
][
"list"
]
db
=
pymysql
.
connect
(
host
=
conf
[
"mysql"
][
"host"
],
port
=
conf
[
"mysql"
][
"port"
],
user
=
conf
[
"mysql"
][
"user"
],
database
=
conf
[
"mysql"
][
"database"
],
password
=
conf
[
"mysql"
][
"password"
])
cursor
=
db
.
cursor
()
for
i
in
range
(
len
(
data
)):
parent_id
=
data
[
i
][
"fid"
]
class_id
=
data
[
i
][
"id"
]
class_name
=
data
[
i
][
"name"
]
depth
=
data
[
i
][
"lev"
]
status
=
1
platform
=
3
create_time
=
int
(
time
.
time
())
select_sql
=
"select id from lie_shop_class where platform = 3 and class_id =
%
s"
cursor
.
execute
(
query
=
select_sql
,
args
=
(
class_id
,))
db_result
=
cursor
.
fetchall
()
if
len
(
db_result
)
==
0
:
sql
=
"insert into lie_shop_class (parent_id, class_id, class_name, depth, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
cursor
.
execute
(
query
=
sql
,
args
=
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
db
.
commit
()
print
(
sql
%
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
if
__name__
==
'__main__'
:
option
=
{
"dev"
,
"prod"
}
if
len
(
sys
.
argv
)
>=
2
and
sys
.
argv
[
1
]
in
option
:
environment
=
sys
.
argv
[
1
]
else
:
print
(
"命令选项:
\n
线上:python3 crontab_pop.py prod
\n
测试:python3 crontab_pop.py dev
\n
"
)
sys
.
exit
(
1
)
config
=
config_dev
if
environment
==
"dev"
:
config
=
config_dev
elif
environment
==
"prod"
:
config
=
config_prod
update_pop_class
(
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