def load_meetings(): """Load meetings from source CSV into database.""" print "Importing meetings..." # Delete all rows in table, so if we need to run this a second time, # we won't be trying to add duplicate retailers Meeting.query.delete() # Read CSV file with open("seed_data/meetings.csv") as source_file: example_data = list(csv.reader(source_file)) # skip header row for populating db for list_item in example_data[1:]: meeting = Meeting(meeting_title=list_item[1], meeting_time=list_item[2], attendees=list_item[3], length=list_item[4], topic_id=list_item[5]) # Add the current retailer to the session db.session.add(meeting) # Commit the db.session changes to the database db.session.commit()
def load_meetings(): """Load meetings into db""" print("Meetings") #Delete row to avoid duplicates Meeting.query.delete() meeting_rows = csv.DictReader(open('data/meetings.csv')) for meeting in meeting_rows: new_meeting = Meeting(month=meeting["month"], year=meeting["year"]) db.session.add(new_meeting) db.session.commit()