gtfs icon indicating copy to clipboard operation
gtfs copied to clipboard

No longer working with SQLAlchemy 0.7.5

Open alibitek opened this issue 13 years ago • 1 comments

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'>

alibitek avatar Mar 03 '12 13:03 alibitek

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:

  1. In gtfs/entity/map_entities.py under create_and_map_tables() change order_by="stop_sequence" to order_by=stop_times_table.c.stop_sequence (this will fix the problem you've mentioned). order_by can't take a string as far as I know.
  2. 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, record loop you could insert if any(record.to_dict().values()): and reindent the rest.

andrewblim avatar Sep 12 '12 19:09 andrewblim