У меня есть следующий метод: я выбираю все идентификаторы из таблицы и добавляю их в список и возвращаю этот список. Но при выполнении этого кода я заканчиваю тем, что индексы кортежей должны быть целыми... ошибка. Я приложил ошибку и распечатку вместе с моим методом:
def questionIds(con):
print 'getting all the question ids'
cur = con.cursor()
qIds = []
getQuestionId = "SELECT question_id from questions_new"
try:
cur.execute(getQuestionId)
for row in cur.fetchall():
print 'printing row'
print row
qIds.append(str(row['question_id']))
except Exception, e:
traceback.print_exc()
return qIds
Печать того, что делает мой метод:
Database version : 5.5.10
getting all the question ids
printing row
(u'20090225230048AAnhStI',)
Traceback (most recent call last):
File "YahooAnswerScraper.py", line 76, in questionIds
qIds.append(str(row['question_id'][0]))
TypeError: tuple indices must be integers, not str