@@ -56,6 +56,7 @@ def __init__(self, url, **kwargs):
5656 # Create engine, disabling SQLAlchemy's own autocommit mode, raising exception if back end's module not installed
5757 self ._engine = sqlalchemy .create_engine (url , ** kwargs ).execution_options (autocommit = False )
5858
59+ # Get logger
5960 self ._logger = logging .getLogger ("cs50" )
6061
6162 # Listener for connections
@@ -77,7 +78,6 @@ def connect(dbapi_connection, connection_record):
7778 # Register listener
7879 sqlalchemy .event .listen (self ._engine , "connect" , connect )
7980
80-
8181 # Test database
8282 disabled = self ._logger .disabled
8383 self ._logger .disabled = True
@@ -282,17 +282,17 @@ def execute(self, sql, *args, **kwargs):
282282
283283 # If not yet connected to this database
284284 # https://flask.palletsprojects.com/en/1.1.x/appcontext/#storing-data
285- if id ( self ) not in connections :
285+ if self not in connections :
286286
287287 # Connect to database
288- connections [id ( self ) ] = self ._engine .connect ()
288+ connections [self ] = self ._engine .connect ()
289289
290290 # Disconnect from database later
291291 if _teardown_appcontext not in flask .current_app .teardown_appcontext_funcs :
292292 flask .current_app .teardown_appcontext (_teardown_appcontext )
293293
294294 # Use this connection
295- connection = connections [id ( self ) ]
295+ connection = connections [self ]
296296
297297 except (ModuleNotFoundError , AssertionError ):
298298
0 commit comments