Skip to content

Commit

Permalink
Fix unique constraint error
Browse files Browse the repository at this point in the history
  • Loading branch information
evelyn9191 committed Feb 1, 2020
1 parent 55f3e4a commit 7f96fc6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gtfspy/import_loaders/stop_times_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def index(cls, cur):
# This is used for the stop frequencies analysis.
#cur.execute('CREATE INDEX idx_stop_times_tid_ath_sid ON stop_times (trip_I, arr_time_hour, stop_id)')
# ^-- much slower than the next index.
cur.execute('CREATE INDEX idx_stop_times_ath_tid_sid ON stop_times (arr_time_hour, trip_I, stop_I)')
cur.execute('CREATE INDEX IF NOT EXISTS idx_stop_times_ath_tid_sid ON stop_times (arr_time_hour, trip_I, stop_I)')

# This has now been moved to DayTripsMaterializer, but is left
# here in case we someday want to make DayTripsMaterializer
Expand Down
2 changes: 1 addition & 1 deletion gtfspy/import_loaders/table_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def insert_data(self, conn):
# proceed. Since there is nothing to import, just continue the loop
print("Not importing %s into %s for %s" % (self.fname, self.table, prefix))
continue
stmt = '''INSERT INTO %s (%s) VALUES (%s)''' % (
stmt = '''INSERT OR REPLACE INTO %s (%s) VALUES (%s)''' % (
self.table,
(', '.join([x for x in fields if x[0] != '_'] + self.extra_keys)),
(', '.join([":" + x for x in fields if x[0] != '_'] + self.extra_values))
Expand Down

0 comments on commit 7f96fc6

Please sign in to comment.