Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
e00229dd
Commit
e00229dd
authored
Aug 22, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加批量从数据库查询数据
parent
6ff78a67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
diaryQueueUpdate.py
diaryQueueUpdate.py
+26
-17
No files found.
diaryQueueUpdate.py
View file @
e00229dd
...
...
@@ -8,6 +8,7 @@ import utils
import
warnings
from
multiprocessing
import
Pool
from
config
import
*
import
time
def
test_con_sql
(
device_id
):
...
...
@@ -125,27 +126,33 @@ def save_result(queue_name, x_list):
def
merge_score
(
x_list
,
score_df
):
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'eagle'
)
cursor
=
db
.
cursor
()
print
(
"连接蔡成功"
)
score_list
=
[]
# 去除diary_id 前面的"diary|"
x_list
=
list
(
map
(
lambda
x
:
x
[
6
:],
x_list
))
for
i
in
x_list
:
sql
=
"select score from biz_feed_diary_score where diary_id = '{}';"
.
format
(
i
)
cursor
.
execute
(
sql
)
if
cursor
.
execute
(
sql
)
!=
0
:
result
=
cursor
.
fetchone
()[
0
]
score_list
.
append
(
result
)
print
(
"成功获取"
)
# 没有查到这个diary_id,默认score值是0
else
:
print
(
"结果是空"
)
score_list
.
append
(
0
)
start
=
time
.
time
()
db
.
close
()
sql
=
"select score from biz_feed_diary_score where diary_id in '{}';"
.
format
(
tuple
(
x_list
))
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
score_list
=
list
(
result
)
#score_list = []
# for i in x_list:
# sql = "select score from biz_feed_diary_score where diary_id = '{}';".format(i)
# cursor.execute(sql)
# if cursor.execute(sql) != 0:
# result = cursor.fetchone()[0]
# score_list.append(result)
# print("成功获取")
# # 没有查到这个diary_id,默认score值是0
# else:
# print("结果是空")
# score_list.append(0)
db
.
close
()
end
=
time
.
time
()
score_df
[
"score"
]
=
score_df
[
"score"
]
+
score_list
print
(
"
done merge"
)
print
(
"
更新分数耗时:{}分"
.
format
((
end
-
start
)
/
60
)
)
update_dairy_queue
(
score_df
)
...
...
@@ -169,11 +176,13 @@ def update_dairy_queue(score_df):
for
j
in
video_id
:
diary_id
.
insert
(
i
,
j
)
i
+=
5
print
(
"排序成功1"
)
return
diary_id
else
:
score_df
=
score_df
.
sort_values
(
by
=
"score"
,
ascending
=
False
)
print
(
"排序成功2"
)
return
score_df
[
"cid"
]
.
values
.
tolist
()
print
(
"排序成功"
)
def
update_sql_dairy_queue
(
queue_name
,
diary_id
):
...
...
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