OpenTransitTools / gtfsdb

GTFS ORM using SQLAlchemy
Mozilla Public License 2.0
157 stars 45 forks source link

MySQL: importing calendar.txt requires type SmallInteger for the days columns #20

Closed celron closed 6 years ago

celron commented 7 years ago

I'm using OpenTransitTools to import tables into mysql. In general it works fine except for calendars.txt. For some reason all the values (monday to sunday) are set to one, even though there are distinct weekend and weekday schedules

I've gone through the code and it reads and parses the file correctly, I suspect that it has something to do with the boolean datatype and mysql in sqlalchemy, and am wondering if it has problem translating the 0's and 1's as False and True with mysql.

Unfortunately I'm unfamiliar with SQLalchemy and can't tell where the problem lies.

Here's the file

service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
1,1,1,1,1,1,0,0,20170427,20181231
2,1,1,1,1,1,0,0,20170601,20181231
3,1,1,1,1,1,0,0,20170801,20181231
4,0,0,0,0,0,1,1,20170427,20181231
5,0,0,0,0,0,1,1,20170601,20181231

If you could provide some direction where I might be able to look to resolve the issue, it would be appreciated. I'm looking into possibly changing the column type

celron commented 7 years ago

Actually changing the column type for the days to SmallInteger solved the problem.

I'm not sure if I should submit a pull request since this might be problematic for something that only affects MySQL

Budgiebrain994 commented 6 years ago

Can confirm - occurs for SQLite too. Would be great to see a PR