-
Notifications
You must be signed in to change notification settings - Fork 0
/
import-gtfs.sql
46 lines (38 loc) · 1.61 KB
/
import-gtfs.sql
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
/*
+--------------+ +--------------+ +-------------+
| | | | | |
| stop_times <------------------+ trips <--------------+ routes |
| | | | | |
+-------+------+ +------+-------+ +-------------+
| |
| |
| |
| |
| |
+-------v------+ +------v-------+
| | | |
| stops | | shapes |
| | | |
+--------------+ +--------------+
*/
-- enable CSV import mode
.mode csv
-- define the CSV separator
.separator ','
-- import & create tables, this will not insert the header line of a CSV file as a row
.import input/stops.txt stops
.import input/stop_times.txt stop_times
.import input/trips.txt trips
.import input/routes.txt routes
.import input/calendar.txt calendar
-- create indices to speed up queries
-- TRIPS
create index trips_trip_id on trips (trip_id);
create index trips_service_id on trips (service_id);
-- STOP_TIMES
create index stop_times_trips on stop_times (trip_id);
create index stop_times_stop_id on stop_times (stop_id);
-- STOPS
create index stops_stop_id on stops (stop_id);
-- CALENDAR
create index calendar_service_id on calendar (service_id);