Esempio n. 1
0
 def find_by_complaint_type(self, name, cursor):
     complaint_query = """SELECT * FROM complaints 
     WHERE complaint_type = %s """
     cursor.execute(complaint_query, ('complaint_type',))
     complaint_record =  cursor.fetchone()
     complaint = db.build_from_record(self, complaint_record)
     return complaint 
Esempio n. 2
0
 def state(self, cursor):
     query_str = "SELECT states.* FROM states WHERE id = %s"
     cursor.execute(query_str, (self.state_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.State, record)
Esempio n. 3
0
 def find_by_name(self, name, cursor):
     category_query = """SELECT * FROM categories WHERE name = %s """
     cursor.execute(category_query, (name, ))
     category_record = cursor.fetchone()
     category = db.build_from_record(self, category_record)
     return category
 def zipcode(self, cursor):
     query_str = "SELECT * FROM zipcodes WHERE id = %s"
     cursor.execute(query_str, (self.zipcode_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.Zipcode, record)
 def venue(self, cursor):
     query_str = "SELECT * FROM venues WHERE id = %s"
     cursor.execute(query_str, (self.venue_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.Venue, record)
 def category(self, cursor):
     query_str = "SELECT categories.* FROM categories WHERE id = %s"
     cursor.execute(query_str, (self.venue_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.Category, record)
 def city(self, cursor):
     query_str = "SELECT cities.* FROM cities WHERE id = %s"
     cursor.execute(query_str, (self.city_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.City, record)
 def find_by_code(self, code, cursor):
     query = f"""SELECT * FROM {self.__table__} WHERE code = %s """
     cursor.execute(query, (code, ))
     record = cursor.fetchone()
     obj = db.build_from_record(self, record)
     return obj
 def location(self, cursor):
     location_query = """SELECT * FROM locations WHERE locations.venue_id = %s"""
     cursor.execute(location_query, (self.id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.Location, record)
 def find_by_foursquare_id(self, foursquare_id, cursor):
     foursquare_query = """SELECT * FROM venues WHERE foursquare_id = %s"""
     cursor.execute(foursquare_query, (foursquare_id, ))
     record = cursor.fetchone()
     return db.build_from_record(models.Venue, record)