Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InitAPIData
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZGC_INDEX
InitAPIData
Commits
3d40e543
Commit
3d40e543
authored
Jan 14, 2020
by
rico.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
93863ce1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
checkData.py
checkData.py
+5
-1
initAPIData.py
initAPIData.py
+15
-9
No files found.
checkData.py
View file @
3d40e543
...
@@ -39,6 +39,10 @@ def checkData(check_data):
...
@@ -39,6 +39,10 @@ def checkData(check_data):
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'
}
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'
}
session
=
requests
.
Session
()
session
=
requests
.
Session
()
if
check_data
.
empty
:
print
(
'今日无新增数据'
)
return
check_data
print
(
'共'
+
str
(
len
(
check_data
))
+
'条数据待审核'
)
print
(
'共'
+
str
(
len
(
check_data
))
+
'条数据待审核'
)
result
=
[]
result
=
[]
...
@@ -358,4 +362,4 @@ def checkData(check_data):
...
@@ -358,4 +362,4 @@ def checkData(check_data):
check_data
[
'source'
]
=
source_list
check_data
[
'source'
]
=
source_list
check_data
[
'price'
]
=
price_list
check_data
[
'price'
]
=
price_list
return
check_data
return
check_data
\ No newline at end of file
initAPIData.py
View file @
3d40e543
...
@@ -26,7 +26,6 @@ def initAPIData(base_frm):
...
@@ -26,7 +26,6 @@ def initAPIData(base_frm):
conn
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'admin@2018@)!*'
,
database
=
f
'{base_frm}'
,
autocommit
=
True
)
conn
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'admin@2018@)!*'
,
database
=
f
'{base_frm}'
,
autocommit
=
True
)
cursor
=
conn
.
cursor
()
cursor
=
conn
.
cursor
()
source
=
base_frm
.
replace
(
'_'
,
''
)
.
replace
(
'ZH'
,
''
)
source
=
base_frm
.
replace
(
'_'
,
''
)
.
replace
(
'ZH'
,
''
)
if
source
==
'JD'
:
if
source
==
'JD'
:
...
@@ -61,10 +60,13 @@ def initAPIData(base_frm):
...
@@ -61,10 +60,13 @@ def initAPIData(base_frm):
#筛选出待审核的数据
#筛选出待审核的数据
cursor
.
execute
(
"select id,sku,name,url,source,price from product_all where ziying is null and productcode is null"
)
cursor
.
execute
(
"select id,sku,name,url,source,price from product_all where ziying is null and productcode is null"
)
data
=
(
cursor
.
fetchall
())
data
=
(
cursor
.
fetchall
())
check_data
=
pd
.
DataFrame
(
data
,
columns
=
[
'id'
,
'sku'
,
'name'
,
'url'
,
'source'
,
'price'
])
check_data
_
=
pd
.
DataFrame
(
data
,
columns
=
[
'id'
,
'sku'
,
'name'
,
'url'
,
'source'
,
'price'
])
#审核三大电商数据
#审核三大电商数据
check_data
=
checkData
(
check_data
)
check_data
=
checkData
(
check_data_
)
if
check_data
.
empty
:
return
False
id_pass
=
[]
id_pass
=
[]
id_no_ziying
=
[]
id_no_ziying
=
[]
...
@@ -131,7 +133,7 @@ def initAPIData(base_frm):
...
@@ -131,7 +133,7 @@ def initAPIData(base_frm):
print
(
'完成'
)
print
(
'完成'
)
print
(
'数据初始化处理完成'
)
print
(
'数据初始化处理完成'
)
return
Non
e
return
Tru
e
else
:
else
:
...
@@ -139,7 +141,11 @@ def initAPIData(base_frm):
...
@@ -139,7 +141,11 @@ def initAPIData(base_frm):
cursor
.
execute
(
"select distinct sku from product_all where productcode is null"
)
cursor
.
execute
(
"select distinct sku from product_all where productcode is null"
)
data
=
(
cursor
.
fetchall
())
data
=
(
cursor
.
fetchall
())
sku_list
=
pd
.
DataFrame
(
data
,
columns
=
[
'sku'
])[
'sku'
]
.
tolist
()
sku_list
=
pd
.
DataFrame
(
data
,
columns
=
[
'sku'
])[
'sku'
]
.
tolist
()
if
len
(
sku_list
)
==
0
:
print
(
'今日无新增数据'
)
return
False
sku_check
=
matchSKU
(
sku_list
,
source
)
sku_check
=
matchSKU
(
sku_list
,
source
)
print
(
'sku排重中'
)
print
(
'sku排重中'
)
for
k
,
v
in
sku_check
.
items
():
for
k
,
v
in
sku_check
.
items
():
...
@@ -161,11 +167,11 @@ def initAPIData(base_frm):
...
@@ -161,11 +167,11 @@ def initAPIData(base_frm):
conn
.
commit
()
conn
.
commit
()
print
(
'数据初始化处理完成'
)
print
(
'数据初始化处理完成'
)
return
Non
e
return
Tru
e
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
i
nitAPIData
(
'ZH_SN'
)
i
f
initAPIData
(
'ZH_SN'
):
data_api
=
data_fetch
(
model
=
'LXWL_model'
,
localhost
=
False
,
source
=
'ZH_SN'
)
data_api
=
data_fetch
(
model
=
'LXWL_model'
,
localhost
=
False
,
source
=
'ZH_SN'
)
data_api_table
=
data_api
.
run
()
data_api_table
=
data_api
.
run
()
\ No newline at end of file
\ No newline at end of file
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