Registry / database / gtfs-via-postgres

gtfs-via-postgres

JSON →
library4.11.1jsnpmunverified

Import GTFS Schedule datasets into PostgreSQL for efficient querying, analysis, and GraphQL/RESTful API access. Current stable version 4.11.1, released regularly, requires PostgreSQL >=14 and Node.js >=20.17. Handles daylight saving time correctly, supports frequencies.txt, and creates joined views. Key differentiators: optimized for PostgreSQL query planner, time-expanded views for routing, and PostGraphile/PostgREST integration. Peer dependencies include postgraphile, @graphile-contrib/pg-simplify-inflector, and @graphile/postgis.

npm install gtfs-via-postgres
INSTALL
IMPORT
SIG · GTFS-VIA-POSTGRES
G
gtfs-via-postgres
databasejavascriptv4.11.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

importGtfsViaPostgres
import { importGtfsViaPostgres } from 'gtfs-via-postgres'
const importGtfsViaPostgres = require('gtfs-via-postgres')
ESM-only since v4. Use dynamic import for CommonJS.
timeExpanded
import { timeExpanded } from 'gtfs-via-postgres'
import timeExpanded from 'gtfs-via-postgres'
Named export, not default.
createInflectors
import { createInflectors } from 'gtfs-via-postgres'
Only available in v4+. For GraphQL schema customization.

Imports GTFS CSV files (unzipped) into a PostgreSQL database using the default configuration. Requires PostgreSQL >=14 and Node.js >=20.17.

import { importGtfsViaPostgres } from 'gtfs-via-postgres'; const dbUrl = process.env.PGDATABASE ?? 'postgres://user:password@localhost:5432/gtfs'; const gtfsDir = './gtfs-files'; // directory with unzipped CSV files await importGtfsViaPostgres(dbUrl, gtfsDir); console.log('GTFS data imported successfully.');
Debug
Known issues
breakingPackage is ESM-only since v4. CommonJS require() will fail.
fix
Use import syntax or dynamic import().
affects: >=4.0.0
breakingMinimum Node.js version changed to 20.17 in v4. Older Node.js versions are unsupported.
fix
Upgrade Node.js to >=20.17 or use v3.x (if still available).
affects: >=4.0.0
breakingRequires PostgreSQL >=14. Older versions will fail due to WITH … AS NOT MATERIALIZED syntax.
fix
Upgrade PostgreSQL to >=14.
affects: >=4.0.0
gotchaGTFS files must be unzipped before import. The tool does not handle .zip files.
fix
Unzip the GTFS feed into a directory of CSV files before passing to importGtfsViaPostgres.
affects: all
gotchaThe package generates SQL that includes CREATE EXTENSION postgis. Ensure PostGIS extension is available in your PostgreSQL instance.
fix
Install PostGIS extension or disable its creation via configuration if not needed.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'gtfs-via-postgres'
Package is ESM-only; require() fails.
fix
Use import { importGtfsViaPostgres } from 'gtfs-via-postgres' or dynamic import().
TypeError: pg is not a constructor
Incorrect peer dependency version or missing pg module.
fix
Ensure pg >=8 is installed. npm install pg@8
Error: Must use import to load ES Module
Running package with require() in CommonJS context.
fix
Switch the importing module to ES module (type: "module" in package.json) or use dynamic import().
Upgrade
Version history
4.11.1latest on npm
Audit
Dependencies
postgraphilerequiredrequired for GraphQL schema generation
@graphile-contrib/pg-simplify-inflectorrequiredpeer dependency for PostGraphile inflector customization
@graphile/postgisrequiredpeer dependency for PostGIS support in PostGraphile
Agent activity
8 hits · last 30 days
node
8
Resources
gtfs-via-postgres — npm install gtfs-via-postgres · libregistry