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
a48bf509
authored
Oct 30, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add modify unit
parent
88f0b279
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
crontab_pop.py
crontab_pop.py
View file @
a48bf509
...
...
@@ -277,6 +277,39 @@ def handle_default_unit(conf: dict):
print
(
update_sql
%
(
id
))
def
handle_unit_from_attr_name
(
conf
:
dict
):
"""
pop的单位很多是从 属性名中提取的。
"""
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, attr_name from lie_shop_attr where platform = 3 and input_type != 10 and unit = ''"
cursor
.
execute
(
query
=
select_sql
)
db_result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
db_result
)):
id
=
db_result
[
i
][
0
]
attr_name
=
db_result
[
i
][
1
]
start
=
attr_name
.
find
(
"("
)
end
=
attr_name
.
find
(
")"
)
if
start
==
-
1
or
end
==
-
1
or
start
>=
end
or
start
==
0
:
print
(
attr_name
+
" can't match!!"
)
continue
else
:
unit_str
=
attr_name
[
start
+
1
:
end
]
update_sql
=
"update lie_shop_attr set unit =
%
s, default_unit =
%
s where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
unit_str
,
unit_str
,
id
,))
db
.
commit
()
print
(
update_sql
%
(
unit_str
,
unit_str
,
id
))
if
__name__
==
'__main__'
:
option
=
{
"dev"
,
"prod"
}
if
len
(
sys
.
argv
)
>=
2
and
sys
.
argv
[
1
]
in
option
:
...
...
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