Skip to content

Instantly share code, notes, and snippets.

@danidee10
Last active January 15, 2018 22:01
Show Gist options
  • Save danidee10/a597bbc92dbb8b5add6eea768b1bc18b to your computer and use it in GitHub Desktop.
Save danidee10/a597bbc92dbb8b5add6eea768b1bc18b to your computer and use it in GitHub Desktop.
Re create database from part 2 of "How to build an online polling application with flask and ReactJS"
from votr import db, Polls, votr
db.app = votr
db.init_app(votr)
db.create_all()
from votr import Polls
from models import Options, Topics, Polls
topic = Topics(title='Which side is going to win the EPL this season')
arsenal = Options(name='Arsenal')
spurs = Options(name='Spurs')
poll = Polls(topic=topic, option=arsenal)
poll1 = Polls(topic=topic, option=spurs)
db.session.add(topic)
db.session.commit()
city = Options(name='Manchester city')
liverpool = Options(name='Liverpool FC')
liverpool = Polls(option=liverpool)
city = Polls(option=city)
new_topic = Topics(title='Whos better liverpool or city', options=[liverpool, city])
db.session.add(new_topic)
db.session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment