@@ -56,6 +56,7 @@ def __init__(self, url, **kwargs):
56
56
# Create engine, disabling SQLAlchemy's own autocommit mode, raising exception if back end's module not installed
57
57
self ._engine = sqlalchemy .create_engine (url , ** kwargs ).execution_options (autocommit = False )
58
58
59
+ # Get logger
59
60
self ._logger = logging .getLogger ("cs50" )
60
61
61
62
# Listener for connections
@@ -77,7 +78,6 @@ def connect(dbapi_connection, connection_record):
77
78
# Register listener
78
79
sqlalchemy .event .listen (self ._engine , "connect" , connect )
79
80
80
-
81
81
# Test database
82
82
disabled = self ._logger .disabled
83
83
self ._logger .disabled = True
@@ -282,17 +282,17 @@ def execute(self, sql, *args, **kwargs):
282
282
283
283
# If not yet connected to this database
284
284
# https://flask.palletsprojects.com/en/1.1.x/appcontext/#storing-data
285
- if id ( self ) not in connections :
285
+ if self not in connections :
286
286
287
287
# Connect to database
288
- connections [id ( self ) ] = self ._engine .connect ()
288
+ connections [self ] = self ._engine .connect ()
289
289
290
290
# Disconnect from database later
291
291
if _teardown_appcontext not in flask .current_app .teardown_appcontext_funcs :
292
292
flask .current_app .teardown_appcontext (_teardown_appcontext )
293
293
294
294
# Use this connection
295
- connection = connections [id ( self ) ]
295
+ connection = connections [self ]
296
296
297
297
except (ModuleNotFoundError , AssertionError ):
298
298
0 commit comments