Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
python_script
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
e2441919
authored
Aug 07, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
script
parent
f79a279d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
handle_ladder_price.py
handle_ladder_price.py
0 → 100644
View file @
e2441919
import
json
import
pymysql
if
__name__
==
'__main__'
:
conf
=
{
'host'
:
"192.168.1.238"
,
'port'
:
3306
,
'user'
:
"europa_erp"
,
'password'
:
"europa_erp#zsyM"
,
'db'
:
"europa_erp"
,
'charset'
:
'utf8'
}
db
=
pymysql
.
connect
(
**
conf
)
cursor
=
db
.
cursor
()
sql
=
"select * from erp_goods_sku where supplier_id = 24"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
result
)):
sku_id
=
str
(
result
[
i
][
0
])
ladder_price
=
result
[
i
][
19
]
ans
=
json
.
loads
(
ladder_price
)
change_arr
=
[]
print
(
ladder_price
)
for
j
in
range
(
len
(
ans
)):
if
'price_cn'
in
ans
[
j
]:
ans
[
j
][
'price_cn'
]
=
0
change_arr
.
append
(
ans
[
j
])
print
(
change_arr
)
if
len
(
change_arr
)
!=
0
:
new_ladder_price
=
json
.
dumps
(
change_arr
)
update_sql
=
"update erp_goods_sku set ladder_price =
%
s where sku_id =
%
s limit 1"
try
:
cursor
.
execute
(
update_sql
,
[
str
(
new_ladder_price
),
sku_id
])
db
.
commit
()
except
Exception
as
e
:
db
.
rollback
()
print
(
e
)
print
(
"------------------------->"
)
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