Quote:
Originally Posted by ownedbycats
What was wrong with it? I've been using update ToC for months and never come across any problems unless there's entries with duplicate names.
|
This line in this function:
Code:
def getDatabaseChapterId(self, bookId, toc_file, connection):
cursor = connection.cursor()
t = ("{0}%{1}%".format(bookId,toc_file),)
cursor.execute('select ContentID from Content where ContentID like ?', t)
try:
result = next(cursor)
chapterContentId = result['ContentID'] # <==============
except StopIteration:
chapterContentId = None
debug_print('getDatabaseChapterId - chapterContentId=%s' % chapterContentId)
cursor.close()
return chapterContentId
The connection was built without a row factory so using the row like a named tuple or a dict can't work. It must be subscripted like a normal tuple.
The fix is
Code:
def getDatabaseChapterId(self, bookId, toc_file, connection):
cursor = connection.cursor()
t = ("{0}%{1}%".format(bookId,toc_file),)
cursor.execute('select ContentID from Content where ContentID like ?', t)
try:
result = next(cursor)
chapterContentId = result[0] #<===============
except StopIteration:
chapterContentId = None
debug_print('getDatabaseChapterId - chapterContentId=%s' % chapterContentId)
cursor.close()
return chapterContentId