No longer working with SQLAlchemy 0.7.5
I've tried to run the test.py script with SQLAlchemy 0.7.5 and ActivePython 2.7.2.5 without any success. I get the following errors several times: "ArgumentError: Column-based expression object expected for argument 'order_by'; got: 'stop_sequence', type <type 'str'>" and "InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Original exception was: Column-based expression object expected for argument 'order_by'; got: 'stop_sequence', type <type 'str'>"
Maybe the order of arguments changed somewhere in the SQL Alchemy API.
Also if I try to create a database from the zippped transit using: import gtfs sched = gtfs.load("google_transit.zip", "transit.db")
I get the following error: sqlalchemy.exc.ArgumentError: Column-based expression object expected for argument 'order_by'; got: 'stop_sequence', type <type 'str'>
I recently forked this project with the intention of playing with it and learning about SQLAlchemy, and ran into the same problems. I got it to work with the following code changes using SQLAlchemy 0.7.8 and using the 10 Sep 2012 BART GTFS data:
- In gtfs/entity/map_entities.py under
create_and_map_tables()changeorder_by="stop_sequence"toorder_by=stop_times_table.c.stop_sequence(this will fix the problem you've mentioned).order_bycan't take a string as far as I know. - Add something to ignore blank lines, as it stands right now it tries to parse them and returns a dict full of Nones, and I found that GTFS data files sometimes contain them. For example in gtfs/loader.py right after the
for i, recordloop you could insertif any(record.to_dict().values()):and reindent the rest.