def __init__(self, first_name, last_name): """ Extends from Person.__init__() to store common data of a person first_name and last_name are string type and storep the first name and last name of a director """ Person.__init__(self, first_name, last_name) self._filmography = [] self.id = '' """Store the movies instances in filmography list""" self.conn = DBManager()
def save_membership(self): """ insert the new membership to database :return: """ conn = DBManager() type = self.get_type() percent = str(self._percent_of_discount) execution_query = "insert into membership values('" + type + "'," + percent + ")" try: conn.query(execution_query) except ValueError: print("there was an error in the process")
def get_discount(self, membership_type): """ Returns the percentage of discount according the membership type method receives the membership type to search the percent discount according membership :return: the percentage from 0 to 100 """ conn = DBManager() discount = 0 execution_query = "select percent_discount from membership where type='" + membership_type + "'" try: discount = conn.query(execution_query).fetchone()[0] except ValueError: print("there was an error in the process") return discount