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
2762907e
Commit
2762907e
authored
Sep 30, 2018
by
高雅喆
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline
add device map to cid
parents
64fb1491
2a1ff68f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
sql_change.py
local/sql_change.py
+36
-0
No files found.
local/sql_change.py
0 → 100644
View file @
2762907e
import
pymysql
import
pandas
as
pd
def
get_data
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'eagle'
)
cursor
=
db
.
cursor
()
sql
=
"select native_queue,nearby_queue,nation_queue,megacity_queue,device_id,city_id from ffm_diary_queue;"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
pd
.
DataFrame
(
list
(
result
))
.
to_csv
(
"/home/gmuser/ffm.csv"
,
index
=
None
)
df
=
pd
.
read_csv
(
"/home/gmuser/ffm.csv"
)
for
i
in
range
(
df
.
shape
[
0
]):
a
=
df
.
loc
[
i
,
:]
.
values
insert
(
a
)
def
insert
(
a
):
db
=
pymysql
.
connect
(
host
=
'rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com'
,
port
=
3306
,
user
=
'doris'
,
passwd
=
'o5gbA27hXHHm'
,
db
=
'doris_prod'
)
sql
=
"INSERT INTO device_diary_queue (native_queue, nearby_queue, nation_queue, "
\
"megacity_queue,device_id,city_id) VALUES ('{}','{}','{}','{}','{}','{}');"
.
format
\
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
])
cursor
=
db
.
cursor
()
cursor
.
execute
(
sql
)
db
.
commit
()
db
.
close
()
print
(
"end"
)
if
__name__
==
"__main__"
:
get_data
()
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