Ejemplo n.º 1
0
	def load_stories(self):
		db = sqlite3.connect('model/news.db')
		c = db.cursor()
		c.execute("SELECT id,title,date,category,story FROM news")
		news_table = c.fetchall()
		for story in news_table:
			c.execute("SELECT id,source,url,headline,story FROM sources WHERE id=?", [story[0]])
			story_sources = c.fetchall()
			sources = []
			for source in story_sources:
				sources.append(Source(source[1],source[2],source[3],source[4]))
			s = Story()
			s.id = story[0]
			s.title = story[1]
			s.date = story[2]
			s.category = story[3]
			s.story = story[4]
			s.sources = sources
			self.stories.append(s)
		c.close()