def createdb(): print 'creating db..' db.drop_all() db.create_all() Role.insert_roles() print 'adding feed sources..' with open('sources.yaml', 'r') as f: feed_sources = yaml.load(f) # Insert feedprovider for site in feed_sources: provider_name = unicode(site['name']) provider_domain = site['domain'] provider = FeedProvider(name = provider_name, domain = provider_domain, favicon = site['favicon']) db.session.add(provider) db.session.commit() # Add feedsource for channel_name in site['channels']: source_name = unicode(site['name'] + ' - ' + channel_name) source_href = site['channels'][channel_name] fs = FeedSource(name=source_name, url=source_href, provider=provider) db.session.add(fs) db.session.commit() print 'add feed articles..' from app.mod_crawler.fetch import update_db update_db()
def updatedb(): from app.mod_crawler.fetch import update_db update_db()