Once the database is created, we can now populate it, as demonstrated in this code listing:
# sqlalchemy_db.py (part 1)1 from sqlalchemy import create_engine2 from sqlalchemy.orm import sessionmaker3 from sqlalchemy_declarative import Tools, Base4 5 engine = create_engine("sqlite:///sqlalchemy_example.db")6 Base.metadata.bind = engine7 8 DBSession = sessionmaker(bind=engine)9 session = DBSession()10 11 box_knife = Tools(name="Box Knife", size="Small", price=15)12 drill = Tools(name="Drill", size="Medium", price=35)13 axe = Tools(name="Axe", size="Large", price=55)14 putty_knife = Tools(name="Putty Knife", size="Small", price=25)15 hammer = Tools(name="Hammer", size="Small", price=25)
Continuing with reimplementing ...