Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unique constraint error #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
- Update to be compatible with networkx 2.0. There should be no
changes needed with networkx 1.11 (it should still work), but bugs
are possible. Please report. Github #34

- Allow one to incrementally update databases with new GTFS files:
`INSERT OR REPLACE` into existing databases (and don't create
indexes if they already exist). It is possible that there are
subtle bugs here - check carefully and report back. #27, thanks to
@evelyn9191 for the change.




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