-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgf sql data pull - fields examp.py
55 lines (44 loc) · 1.8 KB
/
gf sql data pull - fields examp.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import mysql.connector
cnx = mysql.connector.connect(user='root', password='',
host='127.0.0.1',
database='gf_data')
def getDataRange(startDate,startHour, startMin, \
endDate, endHour, endMin,\
symbol):
querystr = "select cp, pr from masterdata where " \
+ "symbol = '" + symbol \
+ "' and " + startDate + " <= time_gathered <= " + endDate \
+ " and hour(time_gathered) <= " + endHour \
+ " and " + startHour + " <= hour(time_gathered) " \
+ " and minute(time_gathered) <= " + endMin \
+ " and " + startMin + " <= minute(time_gathered) ;"
print querystr
query = (querystr)
cursor = cnx.cursor()
cursor.execute(query)
data = cursor.fetchall()
for (cp, pr) in data:
print "{}".format(cp)
return tuple(cursor)
def getDataRangeb(startDate,startHour, startMin, \
endDate, endHour, endMin,\
symbol):
querystr = "select cp, pr from masterdata where " \
+ "symbol = '" + symbol \
+ "' and " + startDate + " <= time_gathered <= " + endDate \
+ " and hour(time_gathered) <= " + endHour \
+ " and " + startHour + " <= hour(time_gathered) " \
+ " and minute(time_gathered) <= " + endMin \
+ " and " + startMin + " <= minute(time_gathered) ;"
print querystr
query = (querystr)
cursor = cnx.cursor()
cursor.execute(query)
data = cursor.fetchall()
for cp in data:
print "{}".format(cp)
return tuple(cursor)
getDataRange("2017-02-08", "06", "57", \
"2017-02-08", "12", "59", \
"AMD")
cnx.close()