forked from gtt116/wait4disney
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (34 loc) · 906 Bytes
/
main.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
import disney_api as api
import names
import influxdb
def make_datas():
datapoints = []
for a in api.attractions():
datapoint = {
"measurement": "wait_minutes",
"tags": {
"name": a.name,
"name_zh": names.translate(a.name),
},
"fields": {
"value": a.wait_minutes,
},
}
datapoints.append(datapoint)
print datapoint
return datapoints
def get_influxdb():
host = 'localhost'
port = 8086
user = 'root'
password = 'root'
dbname = 'disney'
db = influxdb.InfluxDBClient(host, port, user, password, dbname)
db.create_database(dbname)
return db
def main():
db = get_influxdb()
datapoints = make_datas()
assert db.write_points(datapoints, database='disney', batch_size=50)
if __name__ == '__main__':
main()