def main(): # process command line args args = init_parser() # create database db = Database(args.database_url, args.schema, args.is_geospatial) db.create() # load GTFS into database gtfs = GTFS(args.file) gtfs.load(db)
def loadToDatabase(writedir, name, gtfsfile): db_type = "sqlite:///" suffix = ".sqlite" dbpath = writedir + "/" + name + suffix dbname = db_type + dbpath print "storing into database as " + dbname db = Database(dbname, None, False) db.create() gtfs = GTFS(gtfsfile) gtfs.load(db) return dbpath
def loadToDatabase(writedir, name, gtfsfile) : db_type = "sqlite:///" suffix = ".sqlite" dbpath = writedir + "/" + name + suffix dbname = db_type + dbpath print "storing into database as " + dbname db = Database(dbname, None, False) db.create() gtfs = GTFS(gtfsfile) gtfs.load(db) return dbpath
def database_load(filename, **kwargs): '''Basic API to load a GTFS zip file into a database arguments: filename: URL or local path to GTFS zip file keyword arguments: batch_size: record batch size for memory management is_geospatial: if database is support geo functions schema: database schema name tables: limited list of tables to load url: SQLAlchemy database url ''' db = Database(**kwargs) db.create() gtfs = GTFS(filename) gtfs.load(db, **kwargs) return db
if ".zip" in feed: source_zips.append(feed) print "Found {} Feeds".format(len(source_zips)) # sources = get_sources() sources = [] # sources = ['/Users/rhunter/Desktop/action_20150129_0101.zip', '/Users/rhunter/Desktop/abq-ride_20150802_0107.zip'] # db_string = 'sqlite:///gtfs.db' # db_string = 'postgresql://*****:*****@test-gtfs.cvklf6ftrsse.us-east-1.rds.amazonaws.com:5432/gtfs_data' db_string = "postgresql://*****:*****@localhost:5432/gtfs_data" db = Database(url=db_string, is_geospatial=True) db.create() try: GTFS.bootstrab_db(db) except IntegrityError: pass meta = { "dataexchange_id": "action", "file_url": "/Users/rhunter/Desktop/action_20150129_0101.zip", "file_name": "action_20150129_0101.zip", "file_checksum": "MD5123123123123", "date_added": 1213154234.0, } database_load(meta, db_url=db_string)