コード例 #1
0
mark_wahlberg = Actor('Mark Wahlberg', date(1971, 6, 5))

# 6 - add actors to movies
bourne_identity.actors = [matt_damon]
furious_7.actors = [dwayne_johnson]
pain_and_gain.actors = [dwayne_johnson, mark_wahlberg]

# 7 - add contact details to actors
matt_contact = ContactDetails('415 555 2671', 'Burbank, CA', matt_damon)
dwayne_contact = ContactDetails('423 555 5623', 'Glendale, CA', dwayne_johnson)
dwayne_contact_2 = ContactDetails('421 444 2323', 'West Hollywood, CA',
                                  dwayne_johnson)
mark_contact = ContactDetails('421 333 9428', 'Glendale, CA', mark_wahlberg)

# 8 - create stuntmen
matt_stuntman = Stuntman('John Doe', True, matt_damon)
dwayne_stuntman = Stuntman('John Roe', True, dwayne_johnson)
mark_stuntman = Stuntman('Richard Roe', True, mark_wahlberg)

# 9 - persists data
session.add(bourne_identity)
session.add(furious_7)
session.add(pain_and_gain)

session.add(matt_contact)
session.add(dwayne_contact)
session.add(dwayne_contact_2)
session.add(mark_contact)

session.add(matt_stuntman)
session.add(dwayne_stuntman)
コード例 #2
0
mark_wahlberg = Actor("Mark Wahlberg", date(1971, 6, 5))

# 6 - add actors to movies
bourne_identity.actors = [matt_damon]
furious_7.actors = [dwayne_johnson]
pain_and_gain.actors = [dwayne_johnson, mark_wahlberg]

# 7 - add contact details to actors
matt_contact = ContactDetails("415 555 2671", "Burbank, CA", matt_damon)
dwayne_contact = ContactDetails("423 555 5623", "Glendale, CA", dwayne_johnson)
dwayne_contact_2 = ContactDetails("421 444 2323", "West Hollywood, CA",
                                  dwayne_johnson)
mark_contact = ContactDetails("421 333 9428", "Glendale, CA", mark_wahlberg)

# 8 - create stuntmen
matt_stuntman = Stuntman("John Doe", True, matt_damon)
dwayne_stuntman = Stuntman("John Doe", True, dwayne_johnson)
mark_stuntman = Stuntman("Richard Doe", True, mark_wahlberg)

# 9 - persists data
session.add(bourne_identity)
session.add(furious_7)
session.add(pain_and_gain)

session.add(matt_contact)
session.add(dwayne_contact)
session.add(dwayne_contact_2)
session.add(mark_contact)

session.add(matt_stuntman)
session.add(dwayne_stuntman)
コード例 #3
0
# 6 - add actors to movies
bourne_identity.actors = [matt_damon]
furious_7.actors = [dwayne_johnson]
pain_and_gain.actors = [dwayne_johnson, mark_wahlberg]

# 7 - add contact details to actors
matt_contact = ContactDetails(1, "415 555 2671", "Burbank, CA", matt_damon)
dwayne_contact = ContactDetails(2, "423 555 5623", "Glendale, CA",
                                dwayne_johnson)
dwayne_contact_2 = ContactDetails(3, "421 444 2323", "West Hollywood, CA",
                                  dwayne_johnson)
mark_contact = ContactDetails(4, "421 333 9428", "Glendale, CA", mark_wahlberg)

# 8 - create stuntmen
matt_stuntman = Stuntman(1, "John Doe", True, matt_damon)
dwayne_stuntman = Stuntman(2, "John Roe", True, dwayne_johnson)
mark_stuntman = Stuntman(3, "Richard Roe", True, mark_wahlberg)

# 9 - persists data
session.add(bourne_identity)
session.add(furious_7)
session.add(pain_and_gain)

session.add(matt_contact)
session.add(dwayne_contact)
session.add(dwayne_contact_2)
session.add(mark_contact)

session.add(matt_stuntman)
session.add(dwayne_stuntman)
コード例 #4
0
#add actors to movies
movie_1.actors = [actor_1]
movie_2.actors = [actor_2]
movie_3.actors = [actor_3]
movie_4.actors = [actor_4]
movie_5.actors = [actor_5, actor_1]

#add contact details to actors
actor_1_contact = ContactDetails("12 1234 1234", "Address 1", actor_1)
actor_2_contact = ContactDetails("12 1234 1234", "Address 2", actor_2)
actor_3_contact = ContactDetails("12 1234 1234", "Address 3", actor_3)
actor_4_contact = ContactDetails("12 1234 1234", "Address 4", actor_4)
actor_5_contact = ContactDetails("12 1234 1234", "Address 5", actor_5)

#create stuntmen
actor_1_stuntman = Stuntman("Stuntman 1", True, actor_1)
actor_2_stuntman = Stuntman("Stuntman 2", True, actor_2)
actor_3_stuntman = Stuntman("Stuntman 3", True, actor_3)
actor_4_stuntman = Stuntman("Stuntman 4", True, actor_4)
actor_5_stuntman = Stuntman("Stuntman 5", True, actor_5)

#persist data
#SQLAlchemy uses the save-update cascade strategy
#movie
session.add(movie_1)
session.add(movie_2)
session.add(movie_3)
session.add(movie_4)
session.add(movie_5)
#contact
session.add(actor_1_contact)
コード例 #5
0
ファイル: inserts.py プロジェクト: mugoh/dummyV1.1
born_funny.actors = [skim_phew]
catchy.actors = [short_face]
making_soda.actors = [short_face, longer_nose, stop_theft]

# Add contact details to actors

skim_contact = ContactDetails("29 29 29", "Front Street 3", skim_phew)
stop_contact = ContactDetails("42 40 65 44", "Cool Desert 96", stop_theft)
short_contact = ContactDetails("47 85 03 64", "Empty Waters 32", short_face)
longer_contact = ContactDetails("84 43 58 00", "Empty Waters 32", longer_nose)
stop_contact1 = ContactDetails("92 84 83 54", "Hidden Houses 54", stop_theft)

# Create stuntman

skim_stunt = Stuntman("Jumping Tree", True, skim_phew)
stop_stunt = Stuntman("Fallen Roof", True, stop_theft)
long_stunt = Stuntman("Biscuit Man", True, longer_nose)
short_stunt = Stuntman("Walking Slipper", True, short_face)

# Persist data

session.add(born_funny)
session.add(catchy)
session.add(making_soda)

session.add(skim_contact)
session.add(stop_contact)
session.add(stop_contact1)
session.add(longer_contact)
session.add(short_contact)