Gathering detailed insights and metrics for dtd2mysql
Gathering detailed insights and metrics for dtd2mysql
Gathering detailed insights and metrics for dtd2mysql
Gathering detailed insights and metrics for dtd2mysql
MySQL / MariaDB import for DTD feeds (fares, timetable and routeing)
npm install dtd2mysql
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (99.98%)
Shell (0.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
31 Stars
348 Commits
12 Forks
3 Watchers
5 Branches
8 Contributors
Updated on Feb 19, 2025
Latest Version
6.6.1
Package Id
dtd2mysql@6.6.1
Unpacked Size
1.07 MB
Size
153.66 kB
File Count
321
NPM Version
10.7.0
Node Version
20.14.0
Published on
Jun 25, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
An import tool for the British rail fares, routeing and timetable feeds into a database.
Although both the timetable and fares feed are open data you will need to obtain the fares feed via the ATOC website. The formal specification for the data inside the feed also available on the ATOC website.
At the moment only MySQL compatible databases are supported but it could be extended to support other data stores. PRs are very welcome.
You don't have to install it globally but it makes it easier if you are not going to use it as part of another project. The -g
option usually requires sudo
. It is not necessary to git clone this repository unless you would like to contribute.
npm install -g dtd2mysql
Each of these commands relies on the database settings being set in the environment variables. For example DATABASE_USERNAME=root DATABASE_NAME=fares dtd2mysql --fares-clean
.
Import the fares into a database, creating the schema if necessary. This operation is destructive and will remove any existing data.
dtd2mysql --fares /path/to/RJFAFxxx.ZIP
Removes expired data and invalid fares, corrects railcard passenger quantities, adds full date entries to restriction date records. This command will occasionally fail due to a MySQL timeout (depending on hardware), re-running the command should correct the problem.
dtd2mysql --fares-clean
Import the timetable information into a database, creating the schema if necessary. This operation is destructive and will remove any existing data.
dtd2mysql --timetable /path/to/RJTTFxxx.ZIP
Convert the DTD/TTIS version of the timetable (up to 3 months into the future) to GTFS.
dtd2mysql --timetable /path/to/RJTTFxxx.ZIP
dtd2mysql --gtfs-zip filename-of-gtfs.zip
dtd2mysql --routeing /path/to/RJRGxxxx.ZIP
# optional
dtd2mysql --nfm64 /path/to/nfm64.zip
The download commands will take the latest full refresh from an SFTP server (by default the DTD server).
Requires the following environment variables:
SFTP_USERNAME=dtd_username
SFTP_PASSWORD=dtd_password
SFTP_HOSTNAME=dtd_hostname (this will default to dtd.atocrsp.org)
There is a command for each feed
dtd2mysql --download-fares /path/
dtd2mysql --download-timetable /path/
dtd2mysql --download-routeing /path/
dtd2mysql --download-nfm64 /path/
Or download and process in one command
dtd2mysql --get-fares
dtd2mysql --get-timetable
dtd2mysql --get-routeing
dtd2mysql --get-nfm64
Values marked as all asterisks, empty spaces, or in the case of dates - zeros, are set to null. This is to preverse the integrity of the column type. For instance a route code is numerical although the data feed often uses ***** to signify any so this value is converted to null.
Although every record format has a composite key defined in the specification an id
field is added as the fields in the composite key are sometimes null. This is no longer supported in modern versions of MariaDB or MySQL.
At present journey segments, class legends, rounding rules, print formats and the fares data feed meta data are not imported. They are either deprecated or irrelevant. Raise an issue or PR if you would like them added.
The timetable data does not map to a relational database in a very logical fashion so all LO, LI and LT records map to a single stop_time
table.
Only schedule records that start up to 3 months into the future (using date of import as a reference point) are exported to GTFS for performance reasons. This will cause any data after that point to be either incomplete or incorrect, as override/cancellation records after that will be ignored as well.
Issues and PRs are very welcome. To get the project set up run
git clone git@github.com:planarnetwork/dtd2mysql
npm install --dev
npm test
If you would like to send a pull request please write your contribution in TypeScript and if possible, add a test.
This software is licensed under GNU GPLv3.
Copyright 2017 Linus Norton.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
1 existing vulnerabilities detected
Details
Reason
Found 15/26 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More