我试图从MySQL表中检索数据。在
我的代码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
错误:
TypeError:“long”对象没有属性“getitem”
这是我一直得到的错误。它会返回一个元组,所以我不太确定