cs50/python-cs50

Allow for multiple database connections in the same request

jsarchibald opened this issue · 2 comments

Issue when a user has two or more databases -- say, test1.db and test2.db -- that they try to use in the same request. The way the library currently works, whichever database I execute on first in this request will be the only database I'm allowed to connect to in the request. So if I try test1.execute(...) followed by test2.execute(...) in the same request, I'm not going to get what I wanted, since the library limits us to one database connection per request -- in this case, the library will try to execute my second SQL statement on test1.db. And that's because of the request global flask.g._connection we're setting, and then using as a gatekeeper against opening new connections.

Thanks, good catch!

Fixed by #122.