Ingestion works successfully when you ingest it into a blank database (or when you have completely new routes) - but on the second attempt, when there are already routes in the database, ingestion fails.
It appears to have to do with the relationship between the Pickup and the Route objects, but for whatever reason, the lookup table that is being used in the monthly reports manager isn't getting access to the id of the route, even though that database access comes first. This does work on the initial ingestion though.
I'm not really sure what to do, but possible fixes included:
- Having the monthly report object have access to the database (sigh)
- Wrapping the ingestion in a autocommit=False
Here is the error:
sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (IntegrityError) null value in column "route_id" violates not-null constraint
DETAIL: Failing row contains (1, 2014-03-03, null, 10G760, 31, 23540, 2014-07-17 11:49:52.829963-04, 2014-07-17 11:53:02.458993-04).
'UPDATE pickups SET route_id=%(route_id)s, updated=%(updated)s WHERE pickups.id = %(pickups_id)s' {'route_id': None, 'updated': datetime.datetime(2014, 7, 17, 11, 53, 2, 458993, tzinfo=tzlocal()), 'pickups_id': 1}
Ingestion works successfully when you ingest it into a blank database (or when you have completely new routes) - but on the second attempt, when there are already routes in the database, ingestion fails.
It appears to have to do with the relationship between the
Pickupand theRouteobjects, but for whatever reason, the lookup table that is being used in the monthly reports manager isn't getting access to the id of the route, even though that database access comes first. This does work on the initial ingestion though.I'm not really sure what to do, but possible fixes included:
Here is the error: