MySQL 테이블에서 데이터를 검색하려고합니다.TypeError : 'long'객체에 MySQL의 '__getitem__'속성이 없습니다.
내 코드
def getData(self, ID):
#Load data from MySQL
query = 'SELECT * FROM goals WHERE ID = "%s"'% (ID)
try :
cursor.execute(query)
data = cursor.fetchone()
conn.commit()
except Exception as e:
raise e
data = False
if data is not False:
for row in data:
self.ID = row[0]
self.description = row[1]
self.imageID = row[2]
self.imageLink = row[3]
self.Location = row[4]
self.status = row[5]
self.publishID = row[6]
self.goardID = row[7]
self.LikesID = row[8]
self.createdDate = row[9]
self.createdTime = row[10]
self.hide = row[11]
x = newThink()
print x.create_New()
print x.goalID, x.subscriptionID, x.LikesID, x.goardID
see = x.addData('Just the Second', 'Nairobi', 89900845,'http://image.com/789900845')
print see
see = x.postData()
print see
see = x.getData(x.goalID)
print see
print "Now here is the formatted data../n"
print '........'
print x.description, x.Location, x.imageID, x.imageLink
오류 : 형식 오류 : '긴'개체가 어떤 속성 '의 getItem'
이 내가 점점 계속 오류입니다이 없습니다. 튜플을 반환합니다. 그래서 확신 할 수 없습니다.
예외를 발생시키는 행은 무엇입니까? –