Python MySQLdb: connection.close() VS. cursor.close()

If I use MySQLdb to connect to MySQL-Server through Python. I create a connection and a cursor like this:

connection = MySQLdb.connect(...)
cursor = connection.cursor()
# process

When the MySQL-processing is done one should close the connection. Now I was wondering: Is it sufficient to close the connection by doing:

connection.close()

or do I have to close the cursor first and then the connection? Like this:

cursor.close()
connection.close()
51
задан Filipp W. 3 July 2018 в 23:40
поделиться