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
0ef48f57
authored
Oct 23, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add default unit
parent
65e946b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
7 deletions
test6.py
test6.py
View file @
0ef48f57
...
...
@@ -2,16 +2,68 @@
import
json
import
pymysql
from
common
import
request_to_jd_vc
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
main
():
method_name
=
"jingdong.vc.item.brands.find"
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
app_key
=
"CA52430E90209F51D8F5D7B615DDE9AD"
app_secret
=
"c92691b2379c48de87e699c4c2f7fb32"
param
=
{}
ans
=
request_to_jd_vc
(
method_name
,
token
,
app_key
,
app_secret
,
param
)
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
"""将unit单位移动到default_unit"""
conf
=
config_prod
db
=
pymysql
.
connect
(
host
=
conf
[
"mysql"
][
"host"
],
port
=
conf
[
"mysql"
][
"port"
],
user
=
conf
[
"mysql"
][
"user"
],
password
=
conf
[
"mysql"
][
"password"
],
database
=
conf
[
"mysql"
][
"database"
])
cursor
=
db
.
cursor
()
select_sql
=
"select id, unit from lie_shop_attr where platform = 1 and input_type = 7"
cursor
.
execute
(
query
=
select_sql
)
db_result
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
db_result
)):
id
=
db_result
[
i
][
0
]
default_unit
=
db_result
[
i
][
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
))
select_sql
=
"select id, unit from lie_shop_attr where platform = 1 and input_type = 10"
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
]
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
,
))
print
(
update_sql
%
(
default_unit
,
id
))
db
.
commit
()
if
__name__
==
'__main__'
:
...
...
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