Skip to content

Commit

Permalink
add a simple script to test connecting to an existing database
Browse files Browse the repository at this point in the history
  • Loading branch information
fpurcell committed May 29, 2015
1 parent 2005cb1 commit b55c477
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion gtfsdb/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from gtfsdb import Database, GTFS


def database_load(filename, **kwargs):
'''Basic API to load a GTFS zip file into a database
Expand Down
8 changes: 7 additions & 1 deletion gtfsdb/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ def gtfsdb_load():
args, kwargs = get_args()
database_load(args.file, **kwargs)


def route_stop_load():
''' written as a test / debug method for RS table loader '''
from gtfsdb import Database, RouteStop
kwargs = get_args()[1]
db = Database(**kwargs)
RouteStop.load(db, **kwargs)

def db_connect_tester():
''' simple routine to connect to an existing database and list a few stops'''
from gtfsdb import Database, Stop
args, kwargs = get_args()
db = Database(**kwargs)
for s in db.session.query(Stop).limit(5):
print s.stop_name

def get_args():
''' database load command-line arg parser and help util...
Expand Down
2 changes: 1 addition & 1 deletion gtfsdb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def next(self):


def get_route_direction_name(headsign, route_long_name, route_direction_name=None):
''' this routine will look first at the headsign '''
''' this routine will look first at the headsign for a route direction name '''
ret_val = headsign
if route_direction_name and headsign == route_long_name:
ret_val = self.trip.trip_headsign
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
entry_points={
'console_scripts': [
'gtfsdb-load = gtfsdb.scripts:gtfsdb_load',
'rs-test = gtfsdb.scripts:route_stop_load'
'rs-test = gtfsdb.scripts:route_stop_load',
'connect-tester = gtfsdb.scripts:db_connect_tester'
]
},
classifiers=(
Expand Down

0 comments on commit b55c477

Please sign in to comment.