Exemplo n.º 1
0
def update_vehicle(
        db:Session, board: str, values: UpdatevahicleValuesType
):
    if student := vehicle_register(db, vehicle_id):
        db.query(retrieve_vehicle()).filter(update_vehicle==update_vehicle).update(values)
        db.commit()
        db.reflesh(update_vehicle)
Exemplo n.º 2
0
def vehicle_register(db: Session, vehicle: update_vehicle):
    """Creates a new vehicle registration from data sent via API"""
    new_vehicle = vehicle(**vehicle.dict())
    db.add(new_vehicle)
    db.commit()

    db.reflesh(new_vehicle)
    return new_vehicle
Exemplo n.º 3
0
def remove_vehicle(db: Session, vehicle_id: str) -> bool:
    if vehicle := retrieve_vehicle(db, vehicle_id):
    db.delete(vehicle)
    db.commit()

    return True

    return Falseclass Veicle(BaseModel):
    veicle_id: (uuid.uuid1(str))
    board: str
    model: str
    like_vehicle: str
Exemplo n.º 4
0
def session_multi_add_commit(Session, list_of_instances):
    sess = Session()
    sess.add_all(list_of_instances)
    sess.commit()
Exemplo n.º 5
0
              town="Norfolk")
c5 = Customer(first_name='Toby',
              last_name='Miller',
              username='******',
              email='*****@*****.**',
              address='1662 Kinney Street',
              town='Wolfden')
c6 = Customer(first_name='Scott',
              last_name='Harvey',
              username='******',
              email='*****@*****.**',
              address='424 Patterson Street',
              town='Beckinsdale')

session.add_all([c1, c2, c3, c4, c5, c6])
session.commit()

i1 = Item(name='Chair', cost_price=9.21, selling_price=10.81, quantity=5)
i2 = Item(name='Pen', cost_price=3.45, selling_price=4.51, quantity=3)
i3 = Item(name='Headphone', cost_price=15.52, selling_price=16.81, quantity=50)
i4 = Item(name='Travel Bag', cost_price=20.1, selling_price=24.21, quantity=50)
i5 = Item(name='Keyboard', cost_price=20.1, selling_price=22.11, quantity=50)
i6 = Item(name='Monitor', cost_price=200.14, selling_price=212.89, quantity=50)
i7 = Item(name='Watch', cost_price=100.58, selling_price=104.41, quantity=50)
i8 = Item(name='Water Bottle', cost_price=20.89, selling_price=25, quantity=50)

session.add_all([i1, i2, i3, i4, i5, i6, i7, i8])
session.commit()

# Create all tables in the engine. This is equivalent to "Create Table"
# statements in raw SQL.