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
015e39df
authored
Nov 13, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add fix shop sku
parent
4dfc2953
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
1 deletions
fix_sku.py
fix_sku2.py
fix_sku3.py
fix_sku.py
View file @
015e39df
...
@@ -45,7 +45,7 @@ def main(conf: dict):
...
@@ -45,7 +45,7 @@ def main(conf: dict):
cursor
=
db
.
cursor
()
cursor
=
db
.
cursor
()
sql
=
"select id, lx_sku_id from lie_shop_sku where id >=
%
s and shop_id = 2 order by id asc limit 10000"
sql
=
"select id, lx_sku_id from lie_shop_sku where id >=
%
s and shop_id = 2 order by id asc limit 10000"
index
=
1
index
=
1
max_id
=
448337
max_id
=
150000
while
index
<=
max_id
:
while
index
<=
max_id
:
cursor
.
execute
(
query
=
sql
,
args
=
(
index
,))
cursor
.
execute
(
query
=
sql
,
args
=
(
index
,))
results
=
cursor
.
fetchall
()
results
=
cursor
.
fetchall
()
...
...
fix_sku2.py
0 → 100644
View file @
015e39df
import
pymysql
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"
}
}
"""
为新增列 sku_sn字段赋值,当前为platform = 1的数据,sku_sn为 sku_id字段的字符串形式。
"""
def
main
(
conf
:
dict
):
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
()
sql
=
"select id, lx_sku_id from lie_shop_sku where id >=
%
s and shop_id = 2 order by id asc limit 10000"
index
=
150000
max_id
=
300000
while
index
<=
max_id
:
cursor
.
execute
(
query
=
sql
,
args
=
(
index
,))
results
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
results
)):
id
=
results
[
i
][
0
]
lx_sku_id
=
results
[
i
][
1
]
sku_sn
=
str
(
lx_sku_id
)
update_sql
=
"update lie_shop_sku set sku_sn =
%
s where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
sku_sn
,
id
,))
db
.
commit
()
print
(
update_sql
%
(
sku_sn
,
id
))
index
+=
10000
if
__name__
==
'__main__'
:
main
(
config_prod
)
fix_sku3.py
0 → 100644
View file @
015e39df
import
pymysql
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"
}
}
"""
为新增列 sku_sn字段赋值,当前为platform = 1的数据,sku_sn为 sku_id字段的字符串形式。
"""
def
main
(
conf
:
dict
):
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
()
sql
=
"select id, lx_sku_id from lie_shop_sku where id >=
%
s and shop_id = 2 order by id asc limit 10000"
index
=
300000
max_id
=
448337
while
index
<=
max_id
:
cursor
.
execute
(
query
=
sql
,
args
=
(
index
,))
results
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
results
)):
id
=
results
[
i
][
0
]
lx_sku_id
=
results
[
i
][
1
]
sku_sn
=
str
(
lx_sku_id
)
update_sql
=
"update lie_shop_sku set sku_sn =
%
s where id =
%
s"
cursor
.
execute
(
query
=
update_sql
,
args
=
(
sku_sn
,
id
,))
db
.
commit
()
print
(
update_sql
%
(
sku_sn
,
id
))
index
+=
10000
if
__name__
==
'__main__'
:
main
(
config_prod
)
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