-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_app_db.py
57 lines (54 loc) · 1.46 KB
/
init_app_db.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
54
55
56
57
import sqlite3
CT_ROUTE = """
CREATE TABLE IF NOT EXISTS `Route` (
`direction` INTEGER,
`specialCode` INTEGER,
`companyDetails` TEXT,
`locFrom` TEXT,
`locTo` TEXT,
`details` TEXT,
`path` TEXT,
`info` TEXT,
`eta` INTEGER,
`displaySeq` INTEGER ,
`typeSeq` INTEGER,
`updateTime` INTEGER,
`typeCode` INTEGER,
`routeStr` TEXT,
`company` TEXT NOT NULL,
`routeNo` TEXT NOT NULL,
`bound` INTEGER NOT NULL,
`variant` INTEGER NOT NULL,
PRIMARY KEY(`company`, `routeNo`, `bound`, `variant`)
);
"""
CT_STOP = """
CREATE TABLE IF NOT EXISTS `Stop` (
`stopStr` TEXT,
`seq` INTEGER,
`name` TEXT,
`locTo` TEXT,
`details` TEXT,
`latitude` REAL,
`longitude` REAL,
`fare` REAL,
`info` TEXT,
`etaStatus` TEXT,
`etaResults` TEXT,
`etaUpdateTime` INTEGER,
`updateTime` INTEGER,
`typeCode` INTEGER,
`routeStr` TEXT,
`company` TEXT NOT NULL,
`routeNo` TEXT NOT NULL,
`bound` INTEGER NOT NULL,
`variant` INTEGER NOT NULL,
PRIMARY KEY(`company`, `routeNo`, `bound`, `variant`, `seq`)
);
"""
if __name__ == "__main__":
# Create app database
with sqlite3.connect("db/app.db") as conn:
db = conn.cursor()
cursor = db.execute(CT_ROUTE)
cursor = db.execute(CT_STOP)