Exemple #1
0
from app import db, Countries, Cities

db.drop_all()
db.create_all()

UK = Countries(name='United Kingdom')
db.session.add(UK)
db.session.commit()

london = Cities(name='London', country=UK)
manchester = Cities(
    name='Manchester',
    country=Countries.query.filter_by(name='United Kingdom').first())
liverpool = Cities(name='Liverpool', country_id=UK.id)

db.session.add(london)
db.session.add(manchester)
db.session.add(liverpool)
db.session.commit()
Exemple #2
0
from app import db, Countries, Cities

db.create_all()

UK = Countries(name = 'United Kingdom')
db.session.add(UK)
db.session.commit()

ldn = Cities(name='London', country = UK)
mcr = Cities(name='Manchester', country = Countries.query.filter_by(name='United Kingdom').first())

db.session.add(ldn)
db.session.add(mcr)
db.session.commit()
Exemple #3
0
from app import db, Countries, Cities

db.create_all()

ITALY = Countries(name='Italy')
db.session.add(ITALY)
db.session.commit()

Rome = Cities(name='Rome', country=ITALY)
#mcr = Cities(name='Manchester', country = Countries.query.filter_by(name='United Kingdom').first())

db.session.add(Rome)
#db.session.add(mcr)
db.session.commit()