-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroute_map.py
More file actions
74 lines (53 loc) · 1.45 KB
/
Copy pathroute_map.py
File metadata and controls
74 lines (53 loc) · 1.45 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sqlite3
from MTA import get_stop_sequence
from csv_to_db import mta_subway_station_query
stops_in_sequence = get_stop_sequence("l")
if stops_in_sequence[0][-1] == "S":
stops_in_sequence.reverse()
for stop in stops_in_sequence:
print(stop, mta_subway_station_query(stop)["stop_name"])
def build_g_stop_database(stops_list):
connection = sqlite3.connect('mtainfo.db')
cursor = connection.cursor()
create_table = """
CREATE TABLE IF NOT EXISTS groute(
id INTEGER PRIMARY KEY,
stop_id TEXT,
stop_name TEXT
)
"""
cursor.execute(create_table)
add_stop = """
INSERT INTO groute(
stop_id,
stop_name
)
VALUES (?, ?)
"""
for stop in stops_list:
cursor.execute(add_stop, [stop[:-1], mta_subway_station_query(stop)["stop_name"]])
connection.commit()
connection.close()
def build_l_stop_database(stops_list):
connection = sqlite3.connect('mtainfo.db')
cursor = connection.cursor()
create_table = """
CREATE TABLE IF NOT EXISTS lroute(
id INTEGER PRIMARY KEY,
stop_id TEXT,
stop_name TEXT
)
"""
cursor.execute(create_table)
add_stop = """
INSERT INTO lroute(
stop_id,
stop_name
)
VALUES (?, ?)
"""
for stop in stops_list:
cursor.execute(add_stop, [stop[:-1], mta_subway_station_query(stop)["stop_name"]])
connection.commit()
connection.close()
# build_l_stop_database(stops_in_sequence)