Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Binyamin Friedman14,615 Points
How does the database locked solution (in the teacher's notes) work?
The code in the teacher's notes fixed the database locked error that was happening. What does database.transaction do and why is the with statement necessary?
cls.create( username=username, email=email, password=generate_password_hash(password), is_admin=admin)
Teacher's notes version:
with DATABASE.transaction(): cls.create( username=username, email=email, password=generate_password_hash(password), is_admin=admin)