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
88f0b279
authored
Oct 30, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add crontab pop.py
parent
16d1fced
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
crontab_pop.py
crontab_pop.py
View file @
88f0b279
...
@@ -220,6 +220,62 @@ def update_pop_attr(conf: dict):
...
@@ -220,6 +220,62 @@ def update_pop_attr(conf: dict):
db
.
commit
()
db
.
commit
()
print
(
delete_sql
%
id
)
print
(
delete_sql
%
id
)
def
handle_vc_unit
(
conf
:
dict
):
"""
用于处理默认单位字段。
default_unit
"""
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
)
cursor
=
db
.
cursor
()
select_sql
=
"select id, unit, input_type from lie_shop_attr where platform = 3 and unit != ''"
cursor
.
execute
(
query
=
select_sql
)
db_result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
db_result
)):
id
=
db_result
[
i
][
0
]
unit
=
db_result
[
i
][
1
]
input_type
=
db_result
[
i
][
2
]
if
input_type
!=
10
:
update_sql
=
"update lie_shop_attr set default_unit =
%
s where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
unit
,
id
,))
db
.
commit
()
print
(
update_sql
%
(
unit
,
id
))
else
:
"""
input_type 为10的单位单独处理。
"""
end
=
str
(
unit
)
.
find
(
","
)
default_unit
=
unit
[
2
:
end
-
1
]
update_sql
=
"update lie_shop_attr set default_unit =
%
s where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
default_unit
,
id
,))
db
.
commit
()
print
(
update_sql
%
(
default_unit
,
id
))
def
handle_default_unit
(
conf
:
dict
):
"""
保持unit与default_unit一致。
"""
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
)
cursor
=
db
.
cursor
()
select_sql
=
"select id, unit from lie_shop_attr where platform = 3 and unit = '' and default_unit != ''"
cursor
.
execute
(
query
=
select_sql
)
db_result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
db_result
)):
id
=
db_result
[
i
][
0
]
update_sql
=
"update lie_shop_attr set default_unit = '' where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
id
,))
db
.
commit
()
print
(
update_sql
%
(
id
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
option
=
{
"dev"
,
"prod"
}
option
=
{
"dev"
,
"prod"
}
...
@@ -235,3 +291,9 @@ if __name__ == '__main__':
...
@@ -235,3 +291,9 @@ if __name__ == '__main__':
config
=
config_prod
config
=
config_prod
update_pop_class
(
config
)
update_pop_class
(
config
)
print
(
"======================> pop分类已更新"
)
print
(
"======================> pop分类已更新"
)
update_pop_attr
(
config
)
print
(
"======================> pop参数已更新"
)
handle_vc_unit
(
config
)
handle_default_unit
(
config
)
print
(
"======================> pop单位处理完毕"
)
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