forked from sidnarayanan/flask_server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate.py
More file actions
33 lines (26 loc) · 942 Bytes
/
migrate.py
File metadata and controls
33 lines (26 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from os import system, path, getenv
import json
import MySQLdb as sql
import sqlite3
basedir = getenv('FLASK_BASE_DIR')
# manage condor tasks through an sqlite3 db
litepath = basedir + '/condor/tasks.sqlite'
lite = sqlite3.connect(litepath, timeout=30)
maria_conn = sql.connect(db='bird_watcher', user='snarayan')
maria = maria_conn.cursor()
select = 'SELECT host,lat,lon,id FROM nodes'
cur = lite.execute(select)
insert = 'INSERT INTO nodes (host,lat,lon,id) VALUES (%s,%s,%s,%s)'
values = cur.fetchall()
print values[0]
for v in values:
maria.execute(insert, v)
maria_conn.commit()
select = 'SELECT task,arg,job_id,timestamp,starttime,host,host_id,exit_code FROM jobs'
cur = lite.execute(select)
insert = 'INSERT INTO jobs (task,arg,job_id,timestamp,starttime,host,host_id,exit_code) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)'
values = cur.fetchall()
print values[0]
for v in values:
maria.execute(insert, v)
maria_conn.commit()