Errors that drive us crazy

Report a typo

Peter Piper is a retired programmer. He is a farmer now, and he lives in Northern England. Last summer, the weather was benign, so his yield was big. He wanted to brag about a little, so he created a database about his results and sent it to all his friends. In this database, he decided to include the information about a vegetable name, its size (big or large), its colour, taste, and a number of gathered vegetables. He used SQLAlchemy to create the Vegetables class, the vegetables table, and the SQLite engine. Everything was fine. Unfortunately, he made an error when he wanted to start a new session and add entries to the database, so the entries couldn't be saved. Help Peter Piper! Find the line with an error and output the correct version.

from sqlalchemy.orm import sessionmaker

Session = sessionmaker(bind=engine)
session = Session

add_veg_1 = Vegetables(name='tomato', size='large', colour='red', taste='sweety', number='300')
add_veg_2 = Vegetables(name='potato', size='big', colour='brown', taste='sweety', number='500')
add_veg_3 = Vegetables(name='onion', size='large', colour='grey', taste='bitter', number='600')

session.add(add_veg_1)
session.add(add_veg_2)
session.add(add_veg_3)

session.commit()
Enter a short text
___

Create a free account to access the full topic