def get_by_board(board_id, sprint_id = None):
	'''
	Get the stories for a board.
		arg: board_id - the id of the board to get stories for
		arg: sprint_id - the id of the sprint the stories belong to. 
			Passing in 'all' gets all the stories, and passing in 'backlog' gets backlogged stories
	'''
	board_id = UUID(board_id)
	
	#set up the query dynamically based on the sprint_id passed in
	sql_str = '''
		SELECT `id`, `name`, `description`, `estimate`, `board_id`, `sprint_id`
		FROM `stories`
		WHERE `board_id`=%s
	'''
	sql_tuple = (board_id.bytes)
	if sprint_id != 'all':

		if sprint_id == 'backlog':
			sql_str += ' AND `sprint_id` is NULL'
		else:
			sql_str += ' AND `sprint_id`=%s'
			sql_tuple = (board_id.bytes, UUID(sprint_id).bytes)

	cursor.execute(sql_str, sql_tuple)
	
	rows = cursor.fetchall()
	stories = []
	for row in rows:
		stories.append(Story(
				binascii.b2a_hex(row[0]),
				row[1],
				row[2],
				float(row[3]),
				binascii.b2a_hex(row[4]),
				binascii.b2a_hex(row[5]) if row[5] is not None else row[5],
				Tasks.get_by_story(binascii.b2a_hex(row[0]))
			)
		)

	return stories