Necessity of explicit cursor.close()

前端 未结 5 1970
既然无缘
既然无缘 2020-12-28 13:57

From time to time, I\'m executing raw queries using connection.cursor() instead of using ORM (since it is definitely not a silver bullet).

I\'ve noticed that in seve

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 14:41

    The explicit calling of cursor.close() might be because of two reasons:

    1. __del__ is not guaranteed to be called and has some issues you can read here and here
    2. Explicit is better than implicit (Zen of Python)

提交回复
热议问题