如果我使用MySQLdb通過python連接到MySQL服務器。我創建了一個連接和一個這樣的光標Python MySQLdb:connection.close()VS. cursor.close()
connection = MySQLdb.connect(...)
cursor = connection.cursor()
# process
當MySQL處理完成後,應關閉連接。現在,我在想:是不是足以關閉bydoing
connection.close()
連接,或者我必須先關閉光標,然後連接?像這樣:
cursor.close()
connection.close()
在一個相關的說明,關閉光標而不是連接可以嗎? – 2016-10-25 12:23:51
可能重複[何時使用MySQLdb關閉遊標](http://stackoverflow.com/questions/5669878/when-to-close-cursors-using-mysqldb) – 2017-03-23 00:26:07