파이썬에서 mysqldb 모듈을 사용하기 시작했고 쿼리를 호출하는 "표준"방법에 문제가있는 것 같습니다.Mysqldb AttributeError : 커서
표준 방법은 커서를 만든 다음 쿼리를 실행하는 것입니다.
AttributeError: cursor
내 데이터베이스 클래스는 다음과 같습니다 : 지금
class Database():
def __init__(self):
server = "localhost"
login = "login"
password = "passws"
database = "DB"
my_conv = { FIELD_TYPE.LONG: int }
self.conn = MySQLdb.connection(user=login, passwd=password, db=database, host=server, conv=my_conv)
self.cursor = self.conn.cursor()
def close(self):
self.conn.close()
def execute(self, query):
self.cursor.execute(query)
return self.cursor.fetchall()
나는 그것이 쿼리를 사용하여 작업을 진행하게 내가 하나를 실체화 할 때
그러나, 그것은 나에게 다음과 같은 오류를 제공합니다 방법을 사용하지만, 표준을 사용하지 않으면 나중에 문제가 생길 것입니다.
아이디어가 있으십니까?
그리고 추적은 어디에 있습니까? –
추적 기능을 통해 AttributeError를 얻을 수 있습니다. 그리고 다음과 같은 경고 :'D : \ ProgramFiles \ Python26 \ lib \ site-packages \ MySQLdb \ __ init__.py:34 : DeprecationWarning : sets 모듈은 sets에서 더 이상 사용되지 않는다 import immutableSet' – Johanna