This library will allow you to query and update GTFS data from an SQLite database in Swift.
Add the following dependency to your Package.swift file:
dependencies: [.package(url: "https://github.com/phisakel/gtfs-db-swift.git", from: "0.3.0")]and to the target:
dependencies: [.product(name: "GtfsDb", package: "gtfs-db-swift")]You can create a new GTFS database with all required tables using GtfsDb.createDatabase(at:):
import GtfsDb
let database = try GtfsDb.createDatabase(at: "path/to/your/database.sqlite")This creates the database file and runs all GTFS schema migrations (agency, stops, routes, trips, stop_times, calendar, calendar_dates, fare_rules, shapes, frequencies, transfers, pathways, feed_info, translations, attributions).
Alternatively, you can create the SQLite database using the gtfs-import command line tool from the node-GTFS library. First, download the GTFS zip and then run the import command, for example:
gtfs-import --gtfsPath ./9_google_transit.zip --sqlitePath ./9_google_transit.sqliteRead the GTFS data from the SQLite database, using the excellent GRDB library, which is included as a dependency to this library. The following code will read the stops from the database:
import GtfsDb
import GRDB
func fetchStops() async throws -> [Stop] {
let dbPath = "path/to/your/database.sqlite"
var config = Configuration()
config.readonly = true
let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
let stops = try await dbQueue.read { db in try Stop.fetchAll(db) }
return stops
}For advanced use cases you can access the DatabaseMigrator directly via makeMigrator() to apply GTFS schema migrations to any GRDB database:
import GtfsDb
import GRDB
let database = try DatabaseQueue()
let migrator = makeMigrator()
try migrator.migrate(database)Publishing a GitHub release now automatically updates the release body with:
- A short
Highlightssection (top commit summaries) - A full
What's Changedlist - A compare link to the previous tag
The workflow is defined in .github/workflows/release-notes.yml and uses scripts/generate-release-notes.sh.
You can also generate notes locally:
bash scripts/generate-release-notes.sh v0.4.0