TrainDelay is a Python package for tracking train delays at various stations using the Deutsche Bahn API. It collects real-time train data, processes delay information, and stores it in a MySQL database for further analysis
Project description
TrainDelay
TrainDelay is a Python package for tracking train delays at various stations using the Deutsche Bahn API. It collects real-time train data, processes delay information, and stores it in a MySQL database for further analysis.
Features
- Fetches train timetable and delay data for specified stations
- Stores train data in a MySQL database
- Logs tracking operations and errors
Requirements
- Get a MySQL Server running on your machine, the database and tables will be created my the module
- Register for the Deutsche Bahn API (free)
- Create a account at: https://developers.deutschebahn.com
- Create a new application using this url: https://developers.deutschebahn.com/db-api-marketplace/apis/application/new and choose a name that you want
- After that save you the client id and the client secret. You need it to interact with the api
- Navigate to all available apis page at: https://developers.deutschebahn.com/db-api-marketplace/apis/product and select the "Timetables" api
- And click the red subscribe button and select your application
- Now you are done and can start using the api
Setup
- Install train_delay using:
pip install train_delay - import module
from train_delay import *
- Create an AuthData object and a DatabaseConfig object
auth_data = AuthData(YOUR_CLIENT_ID, YOUR_CLIENT_SECRET)
database_config = DatabaseConfig(YOUR_DB_HOSTNAME, YOUR_DB_USER, YOUR_DB_PASSWORD, YOUR_DATABASE_NAME)
You can choose the YOUR_DATABASE_NAME freely. The module will create the database and necessary table where all trains will be stored.
- Now you can create a TrainDelayTracker object
train_delay_tracker = TrainDelayTracker(auth_data, database_config)
- Track your desired train stations with the track_station() Method
train_delay_tracker.track_station("Bonn")
- You'll find your trains at YOUR_DATABASE_NAME.trains
Credits
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file train_delay-1.0.0.tar.gz.
File metadata
- Download URL: train_delay-1.0.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35c77851053c6d98652e75a69dde798829c5b4a6558ec5ed55883f7d84b1b1f8
|
|
| MD5 |
d85fd806f8e214a1113b4846ed3166ce
|
|
| BLAKE2b-256 |
5fdd207c520f28a43fa09cebfcd9378a35fa25254db13baff1de1c3773d5359d
|
File details
Details for the file train_delay-1.0.0-py3-none-any.whl.
File metadata
- Download URL: train_delay-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea83c0be6c0163378298eedcdbd8fe0db01888061de69b6ee0697287b22e0393
|
|
| MD5 |
584bab1e5aea299756ed78a8171040dc
|
|
| BLAKE2b-256 |
b5e677149def7a2eca4656c938956d11eef30905fe3a646d2459075c8d567896
|