Can I use with statement with MySQLdb.Connection object?

前端 未结 1 911
一个人的身影
一个人的身影 2021-01-18 04:32

I wonder if I can use the context manager with with the Connection object, and write code like this:

with MySQLdb.connect(...) as c         


        
相关标签:
1条回答
  • 2021-01-18 05:11

    MySQLdb does not support the context manager protocol. Roll your own, or use oursql instead.

    0 讨论(0)
提交回复
热议问题