我正在将代码从SQLite数据库迁移到MySQL,但在使用上下文管理器时出现了以下属性错误。
我已尝试使用mydb.cursor() as cursor、mydb:等组合……
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database="database_name"
cur = mydb.cursor()
with mydb as cursor:
AttributeError: __enter__