コード例 #1
0
    def get_schedule_entries_between_locations(self, src_location, dest_location, limit=-1):
        """
        Should pas in the string labels for the source and dest locations. 
        """
        
        cur = self.db_conn.cursor()
        sql = 'SELECT * FROM schedule_entry WHERE src_loc_id = ? AND dest_loc_id = ? ORDER BY depart_time ASC'
        
        # does this work or do we need to check if > 0?
        if limit:
            sql += ' LIMIT %d' % limit
            
        # get the actual locations
        d_loc = Locations.get_location_by_label(dest_location)
        s_loc = Locations.get_location_by_label(src_location)
        
        cur.execute(sql, s_loc.id, d_loc.id)
        
        cur.close()
        
        row = cur.fetchone()
        if not row:
            return None

        return ScheduleEntry(self.db_conn, row)
コード例 #2
0
 def get_entries_for_schedule_at_loc(self, schedule, loc):
     """
     Should pass in a valid schedule object and the location label
     """
     
     cur = self.db_conn.cursor()
     sql = ('SELECT * FROM schedule_entry'
            ' WHERE schedule_id = ?'
            ' AND src_loc_id = ?')
     src_loc = Locations.get_location_by_label(loc)
     
     cur.execute(sql, schedule.id, src_loc.id)
     
     rows = cur.fetchall()
     cur.close()
     
     return [ScheduleEntry(self.db_conn, row) for row in rows]
コード例 #3
0
    def get_schedule_entries_for_dest_loc(self, location, limit=-1):
        
        cur = self.db_conn.cursor()
        sql = 'SELECT * FORM schedule_entry WHERE dest_loc_id = ? ORDER BY arrive_time ASC'
        
        if limit:
            sql += ' LIMIT %d' % limit
        
        # get the location
        location = Locations.get_location_by_label(location)
        
        cur.execute(sql, location.id)
        cur.close()
        
        row = cur.fetchone()
        if not row:
            return None
        

        return ScheduleEntry(self.db_conn, row)