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! While you're at it, check out some resources Treehouse students have shared here.
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 trialRyan Carson
23,287 PointsTests failing and I can't figure out why. Getting "peewee.OperationalError: Connection already open" Please help!
I'm getting 9 errors on this Code Challenge and I can't figure out why. I've been Googling for over an hour. Argh!
They all say peewee.OperationalError: Connection already open
Here's my Snapshot: https://w.trhou.se/fi4fqi3b3c
1 Answer
Mark Sebeck
Treehouse Moderator 38,304 PointsHi Ryan. I suspect your error is being caused by one of the tests not allowing the @app.after_request to run which is where your g.db.close() is. Which would make sense why you get a connection already opened if it was never closed.
I was able to get rid of the error by adding a close in the @app.before_request before the connect. This is just a band aid. Have to figure out a way to make sure the connections are always closed. Still get one failure with this band aid.
@app.before_request
def before_request():
g.db = models.DATABASE
g.db.close()
g.db.connect()
g.user = current_user
Ryan Carson
23,287 PointsRyan Carson
23,287 PointsThank you so much Mark Sebeck!
Mark Sebeck
Treehouse Moderator 38,304 PointsMark Sebeck
Treehouse Moderator 38,304 PointsYou are welcome Ryan. That's a tough course. I still need to finish it.