# scooter_types = {"company1": "type1", "company1": "type2", "company1": "type3", "company1": "type4",\ # "company2": "type1", "company2": "type2", "company2": "type3", \ # "company3": "type1", "company3": "type2", # "company4": "type1"} # companies = {"name": "company1", "website": "company1.com", "founded": 2001 } # scooter_types.append({"model": "", "max_range": "", "weight": "", "max_speed": "",\ # "company_id": ""}) companies = [] for i in range(4): c = Company() c.name = f"company{i}" c.website = f"company{i}.com" c.founded = 2000 + i companies.append(c) scooter_types = [] for i in range(16): c = random.choice(companies) st = ScooterType() st.model = f"model{random.randint(1,10)}" st.max_range = random.randint(30, 40) st.weight = random.randint(25, 30) st.max_speed = random.randint(20, 25) st.company = c scooter_types.append(st) scooters = [] for i in range(112):
from sqlalchemy.orm import sessionmaker import db from model import Company, ScooterType, Scooter, Base from datetime import datetime import random Session = sessionmaker(db.engine) session = Session() # use the session object and imported classes (Company, Scooter, etc.) # ... to create companies, types and scooters in teh database c1 = Company() c1.name = 'Super Fast Co' c1.website = 'superfast.lol' c1.founded = 2016 c2 = Company() c2.name = 'Not Slow Co' c2.website = 'notslow.lol' c2.founded = 2014 c3 = Company() c3.name = 'Seems Good Co' c3.website = 'seemsgood.lol' c3.founded = 2016 m_model = ["Scoot V1", "Scoot V2", "Scoot V3", "SuperStar v1", "SuperStar v2", "SuperStar v3", "CatchMe v1", "CatchMe v2", "CatchMe v3"] m_range = [100, 110, 120, 130, 140] m_weight = [15, 20, 25, 30] m_speed = [15, 20, 25, 30, 35, 40, 45]
from sqlalchemy.orm import sessionmaker import db from model import Company, ScooterType, Scooter, Base from datetime import datetime import random Session = sessionmaker(db.engine) session = Session() # use the session object and imported classes (Company, Scooter, etc.) # ... to create companies, types and scooters in the database c1 = Company() c1.name = 'Facebook' c1.website = 'www.facebook.com' c1.founded = 2001 c2 = Company() c2.name = 'Apple' c2.website = 'wwww.apple.com' c2.founded = 1995 c3 = Company() c3.name = 'Tesla' c3.website = 'www.tesla.com' c3.founded = 2007 c4 = Company() c4.name = 'Netflix' c4.website = 'www.netflix.com' c4.founded = 2014