-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMysqlFuncs.py
More file actions
39 lines (33 loc) · 1.31 KB
/
Copy pathMysqlFuncs.py
File metadata and controls
39 lines (33 loc) · 1.31 KB
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
34
35
36
37
38
import sys
import MySQLdb as mysql
import datetime,time
def ConnectDB(host, user, passwd):
return mysql.connect(host=host, db='mysql', user=user, passwd=passwd, charset="utf8")
def GetCityPairs(conn, src_db="aie_v2"):
c = conn.cursor(mysql.cursors.DictCursor)
sql = """ select DepartureCode, DestinationCode, country
from %s.aie_citypair
where Undone='TRUE' """ % (src_db)
print "sql = [%s]" % sql
c.execute(sql)
return c.fetchall()
def GetBookCityPairs(conn, src_db="aie_v2"):
c = conn.cursor(mysql.cursors.DictCursor)
sql = """ select leave_date, back_date, leave_city,dest_city
from %s.mail_order
""" % (src_db)
print "sql = [%s]" % sql
c.execute(sql)
return c.fetchall()
def getPasswd():
return "root"
def updatePrice(conn, DepartCity, DestCity, DepartDay, returnDay, datasource, URL):
c = conn.cursor(mysql.cursors.DictCursor)
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sql = """ replace into aie_v2.aie_masterdata
(DepartureDate, ReturnDate, DepartureCity, ArrivalCity, Price, Stops, AirlineCode,AirlineName, WebLink, Undone, updated, UpdatedDate)
values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s, '%s')
""" % (DepartDay, returnDay, DepartCity, DestCity, datasource, '0', '0', '0', URL, 'TRUE', '1', now)
print "sql = [%s]" % sql
c.execute(sql)
conn.commit()