本文整理匯總了Python中graphserver.ext.gtfs.gtfsdb.GTFSDatabase.get_cursor方法的典型用法代碼示例。如果您正苦於以下問題:Python GTFSDatabase.get_cursor方法的具體用法?Python GTFSDatabase.get_cursor怎麽用?Python GTFSDatabase.get_cursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類graphserver.ext.gtfs.gtfsdb.GTFSDatabase
的用法示例。
在下文中一共展示了GTFSDatabase.get_cursor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: copy
# 需要導入模塊: from graphserver.ext.gtfs.gtfsdb import GTFSDatabase [as 別名]
# 或者: from graphserver.ext.gtfs.gtfsdb.GTFSDatabase import get_cursor [as 別名]
routes = copy(param['routes'])
# print xscale, range_lat, range_lon
for sid2, sname2, lat2, lon2 in db.execute(near_query, {'range_lat': range_lat, 'range_lon': range_lon, 'lat': param['lat'], 'lon': param['lon']}):
if sid == sid2:
continue
d = distance (param['lat'], param['lon'], lat2, lon2, xscale)
if d > RADIUS :
continue
if verbose :
print " ", sid2, sname2, '%0.1f m' % d
if sid2 in stops and len(stops[sid2]['routes'] - routes) > 0:
routes = routes.union(stops[sid2]['routes'])
transfers.append ( (sid, sid2, d * OBSTRUCTION) )
n_processed += 1;
if n_processed % 1000 == 0 :
print 'processed %d stops' % n_processed
cur = db.get_cursor()
cur.execute('delete from transfers;') # where transfer_type = 9;')
cur.executemany('insert into transfers values (?,?,9,?);', transfers)
cur.execute('create index if not exists transfers_from_stop_id ON transfers (from_stop_id)')
print 'committing...'
db.conn.commit()
# print 'vacuuming...'
# cur.execute('vacuum;')
# db.conn.commit()