Question 29
Consider the below model definitions, and answer the given subquestions.
Consider the following model classes “Movies” and “Producers” corresponding to tables “movies” and “producers”, respectively, in the SQLite database.
class Movies(db.Model): id = db.Column(db.Integer(), primary_key = True) movie_name = db.Column(db.String(50), nullable = False, unique = True) movie_year = db.Column(db.Integer, nullable = False) producers = db.relationship('Producer', backref = 'movie', secondary = 'groups')
class Producer(db.Model): id = db.Column(db.Integer(), primary_key = True) producer_name = db.Column(db.String(50), nullable = False, unique = True) productions = db.Column(db.Integer())
class Groups(db.Model): movie_id = db.Column(db.Integer(),db.ForeignKey('movies.id'), primary_key = True) prod_id = db.Column(db.Integer(),db.ForeignKey('producer.id'), primary_key = True)If an object “p1” that represents an existing record in the table “producer” is defined as p1 = Producer.query.get(2), The correct way to create a new record in the “movies” table that is produced by the producer represented by object ‘p1’ using terminal is.