I recently discovered the Python with keyword and started seeing its potential usefulness for more prettily handling some scenarios where I
with
See the __enter__ function in this link. https://github.com/PyMySQL/mysqlclient-python/blob/master/MySQLdb/connections.py
__enter__
__enter__ function of connection object returns self.cursor().
self.cursor()
That is why you are getting cursor object instead of Connection object.